Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
helm3
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
helm3
Commits
66477e05
Commit
66477e05
authored
May 02, 2016
by
Michelle Noorali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ref(helm): add helper to check len of cmd args
parent
ef4da356
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
2 deletions
+15
-2
helm.go
cmd/helm/helm.go
+13
-0
repo.go
cmd/helm/repo.go
+2
-2
No files found.
cmd/helm/helm.go
View file @
66477e05
package
main
package
main
import
(
import
(
"fmt"
"os"
"os"
"strings"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
)
)
...
@@ -44,3 +46,14 @@ func init() {
...
@@ -44,3 +46,14 @@ func init() {
func
main
()
{
func
main
()
{
RootCommand
.
Execute
()
RootCommand
.
Execute
()
}
}
func
checkArgsLength
(
expectedNum
,
actualNum
int
,
requiredArgs
...
string
)
error
{
if
actualNum
!=
expectedNum
{
arg
:=
"arguments"
if
expectedNum
==
1
{
arg
=
"argument"
}
return
fmt
.
Errorf
(
"This command needs %v %s: %s"
,
expectedNum
,
arg
,
strings
.
Join
(
requiredArgs
,
", "
))
}
return
nil
}
cmd/helm/repo.go
View file @
66477e05
...
@@ -34,8 +34,8 @@ var repoListCmd = &cobra.Command{
...
@@ -34,8 +34,8 @@ var repoListCmd = &cobra.Command{
}
}
func
runRepoAdd
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
runRepoAdd
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
if
len
(
args
)
!=
2
{
if
err
:=
checkArgsLength
(
2
,
len
(
args
),
"name for the chart repository"
,
"the url of the chart repository"
);
err
!=
nil
{
return
fmt
.
Errorf
(
"This command needs two argument, a name for the chart repository and the url of the chart repository"
)
return
err
}
}
err
:=
insertRepoLine
(
args
[
0
],
args
[
1
])
err
:=
insertRepoLine
(
args
[
0
],
args
[
1
])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment