Error if the resource name is omitted, unless --all is also used.
Signed-off-by: Mauro M. Silva <maumontesilva@gmail.com>
This commit is contained in:
parent
6ba1dcaf43
commit
f703a5409d
@ -112,6 +112,10 @@ func (o *Options) Validate(cmd *cobra.Command, args []string) error {
|
||||
return errors.New("cannot specify --namespace flag in conjunction with --all flag")
|
||||
}
|
||||
|
||||
if !o.All && len(args) == 0 {
|
||||
return errors.New("certificate name(s) is/are required without the --all flag")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@ -72,6 +72,29 @@ func TestValidate(t *testing.T) {
|
||||
},
|
||||
expErr: true,
|
||||
},
|
||||
"If --namespace specified without arguments, error": {
|
||||
options: &Options{},
|
||||
setStringFlags: []stringFlag{
|
||||
{name: "namespace", value: "foo"},
|
||||
},
|
||||
expErr: true,
|
||||
},
|
||||
"If --namespace specified and at least one argument, don't error": {
|
||||
options: &Options{},
|
||||
args: []string{"bar"},
|
||||
setStringFlags: []stringFlag{
|
||||
{name: "namespace", value: "foo"},
|
||||
},
|
||||
expErr: false,
|
||||
},
|
||||
"If --namespace specified with multiple arguments, don't error": {
|
||||
options: &Options{},
|
||||
args: []string{"bar", "abc"},
|
||||
setStringFlags: []stringFlag{
|
||||
{name: "namespace", value: "foo"},
|
||||
},
|
||||
expErr: false,
|
||||
},
|
||||
}
|
||||
|
||||
for name, test := range tests {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user