Merge pull request #42999 from shiywang/fix-return0

Automatic merge from submit-queue (batch tested with PRs 43450, 42999, 43968)

fix kubectl config return 0 on error

Fixes https://github.com/kubernetes/kubernetes/issues/42852
cc @kubernetes/sig-cli-bugs
@ymqytw ptal
This commit is contained in:
Kubernetes Submit Queue
2017-04-03 09:48:23 -07:00
committed by GitHub
7 changed files with 29 additions and 46 deletions

View File

@@ -69,10 +69,7 @@ func NewCmdConfigSetCluster(out io.Writer, configAccess clientcmd.ConfigAccess)
Long: create_cluster_long,
Example: create_cluster_example,
Run: func(cmd *cobra.Command, args []string) {
if !options.complete(cmd) {
return
}
cmdutil.CheckErr(options.complete(cmd))
cmdutil.CheckErr(options.run())
fmt.Fprintf(out, "Cluster %q set.\n", options.name)
},
@@ -155,15 +152,15 @@ func (o *createClusterOptions) modifyCluster(existingCluster clientcmdapi.Cluste
return modifiedCluster
}
func (o *createClusterOptions) complete(cmd *cobra.Command) bool {
func (o *createClusterOptions) complete(cmd *cobra.Command) error {
args := cmd.Flags().Args()
if len(args) != 1 {
cmd.Help()
return false
return fmt.Errorf("Unexpected args: %v", args)
}
o.name = args[0]
return true
return nil
}
func (o createClusterOptions) validate() error {