diff --git a/pkg/kubectl/cmd/delete.go b/pkg/kubectl/cmd/delete.go index 233c00cc964..86f8869abc6 100644 --- a/pkg/kubectl/cmd/delete.go +++ b/pkg/kubectl/cmd/delete.go @@ -113,7 +113,7 @@ type DeleteOptions struct { } func NewCmdDelete(f cmdutil.Factory, out, errOut io.Writer) *cobra.Command { - options := &DeleteOptions{} + options := &DeleteOptions{Include3rdParty: true} validArgs := cmdutil.ValidArgList(f) cmd := &cobra.Command{ diff --git a/pkg/kubectl/cmd/edit.go b/pkg/kubectl/cmd/edit.go index 62ab54a5060..212ce13b963 100644 --- a/pkg/kubectl/cmd/edit.go +++ b/pkg/kubectl/cmd/edit.go @@ -71,7 +71,9 @@ var ( func NewCmdEdit(f cmdutil.Factory, out, errOut io.Writer) *cobra.Command { options := &editor.EditOptions{ - EditMode: editor.NormalEditMode, + EditMode: editor.NormalEditMode, + ValidateOptions: cmdutil.ValidateOptions{EnableValidation: true}, + Include3rdParty: true, } validArgs := cmdutil.ValidArgList(f) diff --git a/pkg/kubectl/cmd/util/helpers.go b/pkg/kubectl/cmd/util/helpers.go index b982d86b873..5a5409c5f57 100644 --- a/pkg/kubectl/cmd/util/helpers.go +++ b/pkg/kubectl/cmd/util/helpers.go @@ -401,7 +401,7 @@ func AddValidateFlags(cmd *cobra.Command) { } func AddValidateOptionFlags(cmd *cobra.Command, options *ValidateOptions) { - cmd.Flags().BoolVar(&options.EnableValidation, "validate", true, "If true, use a schema to validate the input before sending it") + cmd.Flags().BoolVar(&options.EnableValidation, "validate", options.EnableValidation, "If true, use a schema to validate the input before sending it") } func AddFilenameOptionFlags(cmd *cobra.Command, options *resource.FilenameOptions, usage string) { @@ -427,7 +427,7 @@ func AddApplyAnnotationFlags(cmd *cobra.Command) { } func AddApplyAnnotationVarFlags(cmd *cobra.Command, applyAnnotation *bool) { - cmd.Flags().BoolVar(applyAnnotation, ApplyAnnotationsFlag, false, "If true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.") + cmd.Flags().BoolVar(applyAnnotation, ApplyAnnotationsFlag, *applyAnnotation, "If true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.") } // AddGeneratorFlags adds flags common to resource generation commands @@ -524,7 +524,7 @@ func AddRecordFlag(cmd *cobra.Command) { } func AddRecordVarFlag(cmd *cobra.Command, record *bool) { - cmd.Flags().BoolVar(record, "record", false, "Record current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists.") + cmd.Flags().BoolVar(record, "record", *record, "Record current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists.") } func GetRecordFlag(cmd *cobra.Command) bool { @@ -601,7 +601,7 @@ func AddInclude3rdPartyFlags(cmd *cobra.Command) { } func AddInclude3rdPartyVarFlags(cmd *cobra.Command, include3rdParty *bool) { - cmd.Flags().BoolVar(include3rdParty, "include-extended-apis", true, "If true, include definitions of new APIs via calls to the API server. [default true]") + cmd.Flags().BoolVar(include3rdParty, "include-extended-apis", *include3rdParty, "If true, include definitions of new APIs via calls to the API server. [default true]") cmd.Flags().MarkDeprecated("include-extended-apis", "No longer required.") } diff --git a/pkg/kubectl/cmd/util/printing.go b/pkg/kubectl/cmd/util/printing.go index 18098f20f90..8e734d597ef 100644 --- a/pkg/kubectl/cmd/util/printing.go +++ b/pkg/kubectl/cmd/util/printing.go @@ -63,7 +63,7 @@ func AddOutputFlagsForMutation(cmd *cobra.Command) { // AddOutputVarFlagsForMutation adds output related flags to a command. Used by mutations only. func AddOutputVarFlagsForMutation(cmd *cobra.Command, output *string) { - cmd.Flags().StringVarP(output, "output", "o", "", "Output mode. Use \"-o name\" for shorter output (resource/name).") + cmd.Flags().StringVarP(output, "output", "o", *output, "Output mode. Use \"-o name\" for shorter output (resource/name).") } // AddOutputFlags adds output related flags to a command.