Merge pull request #51401 from CaoShuFeng/rename_context

Automatic merge from submit-queue (batch tested with PRs 51401, 54056, 54977, 55017, 55052). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

[cli] exit when Validate() returns an error

cmdutil.UsageErrorf() does nothing but returna a string. When Validate()
returns an error, we should call exit() function.

fix: https://github.com/kubernetes/kubectl/issues/119

**Release note**:
```
NONE
```
This commit is contained in:
Kubernetes Submit Queue 2017-11-03 12:07:53 -07:00 committed by GitHub
commit 97143e51f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -43,7 +43,7 @@ const (
var (
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.
@ -70,7 +70,7 @@ func NewCmdConfigRenameContext(out io.Writer, configAccess clientcmd.ConfigAcces
cmdutil.CheckErr(err)
}
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 {
cmdutil.CheckErr(err)

View File

@ -124,7 +124,7 @@ func (o *ConvertOptions) Complete(f cmdutil.Factory, out io.Writer, cmd *cobra.C
return err
}
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