Skip to content

Commit

Permalink
Merge pull request kubernetes#105445 from ardaguclu/diff-invalid-arg-…
Browse files Browse the repository at this point in the history
…status-code

Add diff command return status code greater than 1 when flags invalid
  • Loading branch information
k8s-ci-robot authored Oct 12, 2021
2 parents 297faec + 4f08485 commit e054181
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions staging/src/k8s.io/kubectl/pkg/cmd/diff/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ func NewCmdDiff(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.C
},
}

// Flag errors exit with code 1, however according to the diff
// command it means changes were found.
// Thus, it should return status code greater than 1.
cmd.SetFlagErrorFunc(func(command *cobra.Command, err error) error {
cmdutil.CheckDiffErr(cmdutil.UsageErrorf(cmd, err.Error()))
return nil
})

usage := "contains the configuration to diff"
cmd.Flags().StringVarP(&options.Selector, "selector", "l", options.Selector, "Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)")
cmdutil.AddFilenameOptionFlags(cmd, &options.FilenameOptions, usage)
Expand Down

0 comments on commit e054181

Please sign in to comment.