mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-19 00:31:00 +00:00
[cli] exit when Validate() return an error
cmdutil.UsageErrorf() does nothing but return a string. When Validate() returns an error, we should call exit() function.
This commit is contained in:
parent
43559fe9df
commit
26032ad6f8
@ -43,7 +43,7 @@ const (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
renameContextLong = templates.LongDesc(`
|
renameContextLong = templates.LongDesc(`
|
||||||
Renames a context from the kubeconfig file .
|
Renames a context from the kubeconfig file.
|
||||||
|
|
||||||
CONTEXT_NAME is the context name that you wish change.
|
CONTEXT_NAME is the context name that you wish change.
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ func NewCmdConfigRenameContext(out io.Writer, configAccess clientcmd.ConfigAcces
|
|||||||
cmdutil.CheckErr(err)
|
cmdutil.CheckErr(err)
|
||||||
}
|
}
|
||||||
if err := options.Validate(); err != nil {
|
if err := options.Validate(); err != nil {
|
||||||
cmdutil.UsageErrorf(cmd, err.Error())
|
cmdutil.CheckErr(cmdutil.UsageErrorf(cmd, err.Error()))
|
||||||
}
|
}
|
||||||
if err := options.RunRenameContext(out); err != nil {
|
if err := options.RunRenameContext(out); err != nil {
|
||||||
cmdutil.CheckErr(err)
|
cmdutil.CheckErr(err)
|
||||||
|
@ -124,7 +124,7 @@ func (o *ConvertOptions) Complete(f cmdutil.Factory, out io.Writer, cmd *cobra.C
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if !scheme.Registry.IsEnabledVersion(o.outputVersion) {
|
if !scheme.Registry.IsEnabledVersion(o.outputVersion) {
|
||||||
cmdutil.UsageErrorf(cmd, "'%s' is not a registered version.", o.outputVersion)
|
return cmdutil.UsageErrorf(cmd, "'%s' is not a registered version.", o.outputVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
// build the builder
|
// build the builder
|
||||||
|
Loading…
Reference in New Issue
Block a user