From 797f0ac660e60701e47c38ce2f2e0a21c8f19ec2 Mon Sep 17 00:00:00 2001 From: Pingan2017 Date: Thu, 18 Oct 2018 11:33:45 +0800 Subject: [PATCH] remove unneed if block for kubectl delete command --- pkg/kubectl/cmd/delete/delete.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/pkg/kubectl/cmd/delete/delete.go b/pkg/kubectl/cmd/delete/delete.go index 7a0c60919d..b34bc9fa75 100644 --- a/pkg/kubectl/cmd/delete/delete.go +++ b/pkg/kubectl/cmd/delete/delete.go @@ -126,7 +126,7 @@ func NewCmdDelete(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra Run: func(cmd *cobra.Command, args []string) { o := deleteFlags.ToOptions(nil, streams) cmdutil.CheckErr(o.Complete(f, args, cmd)) - cmdutil.CheckErr(o.Validate(cmd)) + cmdutil.CheckErr(o.Validate()) cmdutil.CheckErr(o.RunDelete()) }, SuggestFor: []string{"rm"}, @@ -194,9 +194,9 @@ func (o *DeleteOptions) Complete(f cmdutil.Factory, args []string, cmd *cobra.Co return nil } -func (o *DeleteOptions) Validate(cmd *cobra.Command) error { +func (o *DeleteOptions) Validate() error { if o.Output != "" && o.Output != "name" { - return cmdutil.UsageErrorf(cmd, "Unexpected -o output mode: %v. We only support '-o name'.", o.Output) + return fmt.Errorf("unexpected -o output mode: %v. We only support '-o name'.", o.Output) } if o.DeleteAll && len(o.LabelSelector) > 0 { @@ -206,11 +206,6 @@ func (o *DeleteOptions) Validate(cmd *cobra.Command) error { return fmt.Errorf("cannot set --all and --field-selector at the same time") } - if o.GracePeriod == 0 && !o.ForceDeletion && !o.WaitForDeletion { - // With the explicit --wait flag we need extra validation for backward compatibility - return fmt.Errorf("--grace-period=0 must have either --force specified, or --wait to be set to true") - } - switch { case o.GracePeriod == 0 && o.ForceDeletion: fmt.Fprintf(o.ErrOut, "warning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely.\n")