fix kubectl config return 0 on error

This commit is contained in:
shiywang
2017-03-14 00:02:00 +08:00
parent 302aab9ba2
commit 917a0b6f1b
7 changed files with 29 additions and 46 deletions

View File

@@ -60,10 +60,7 @@ func NewCmdConfigSet(out io.Writer, configAccess clientcmd.ConfigAccess) *cobra.
Short: i18n.T("Sets an individual value in a kubeconfig file"),
Long: set_long,
Run: func(cmd *cobra.Command, args []string) {
if !options.complete(cmd) {
return
}
cmdutil.CheckErr(options.complete(cmd))
cmdutil.CheckErr(options.run())
fmt.Fprintf(out, "Property %q set.\n", options.propertyName)
},
@@ -106,16 +103,16 @@ func (o setOptions) run() error {
return nil
}
func (o *setOptions) complete(cmd *cobra.Command) bool {
func (o *setOptions) complete(cmd *cobra.Command) error {
endingArgs := cmd.Flags().Args()
if len(endingArgs) != 2 {
cmd.Help()
return false
return fmt.Errorf("Unexpected args: %v", endingArgs)
}
o.propertyValue = endingArgs[1]
o.propertyName = endingArgs[0]
return true
return nil
}
func (o setOptions) validate() error {