From 3e93f9926279db8a4d064d615c4ad7cfdc7ab38b Mon Sep 17 00:00:00 2001 From: "Julian V. Modesto" Date: Wed, 20 May 2020 16:53:53 -0400 Subject: [PATCH] Remove deprecated --server-dry-run. For the beta server-side dry-run feature, `kubectl apply` provided the `--server-dry-run` flag. As of 1.18, this flag was deprecated and marked to be removed after 1 release. --- staging/src/k8s.io/kubectl/pkg/cmd/apply/apply.go | 12 ------------ test/cmd/apply.sh | 1 - 2 files changed, 13 deletions(-) diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/apply/apply.go b/staging/src/k8s.io/kubectl/pkg/cmd/apply/apply.go index 1d1b6525571..482cea86c94 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/apply/apply.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/apply/apply.go @@ -191,9 +191,6 @@ func NewCmdApply(baseName string, f cmdutil.Factory, ioStreams genericclioptions cmd.Flags().BoolVar(&o.All, "all", o.All, "Select all resources in the namespace of the specified resource types.") cmd.Flags().StringArrayVar(&o.PruneWhitelist, "prune-whitelist", o.PruneWhitelist, "Overwrite the default whitelist with for --prune") cmd.Flags().BoolVar(&o.OpenAPIPatch, "openapi-patch", o.OpenAPIPatch, "If true, use openapi to calculate diff when the openapi presents and the resource can be found in the openapi spec. Otherwise, fall back to use baked-in types.") - cmd.Flags().Bool("server-dry-run", false, "If true, request will be sent to server with dry-run flag, which means the modifications won't be persisted.") - cmd.Flags().MarkDeprecated("server-dry-run", "--server-dry-run is deprecated and can be replaced with --dry-run=server.") - cmd.Flags().MarkHidden("server-dry-run") cmdutil.AddDryRunFlag(cmd) cmdutil.AddServerSideApplyFlags(cmd) cmdutil.AddFieldManagerFlagVar(cmd, &o.FieldManager, FieldManagerClientSideApply) @@ -234,15 +231,6 @@ func (o *ApplyOptions) Complete(f cmdutil.Factory, cmd *cobra.Command) error { return fmt.Errorf("--dry-run=client doesn't work with --server-side (did you mean --dry-run=server instead?)") } - var deprecatedServerDryRunFlag = cmdutil.GetFlagBool(cmd, "server-dry-run") - if o.DryRunStrategy == cmdutil.DryRunClient && deprecatedServerDryRunFlag { - return fmt.Errorf("--dry-run=client and --server-dry-run can't be used together (did you mean --dry-run=server instead?)") - } - - if o.DryRunStrategy == cmdutil.DryRunNone && deprecatedServerDryRunFlag { - o.DryRunStrategy = cmdutil.DryRunServer - } - // allow for a success message operation to be specified at print time o.ToPrinter = func(operation string) (printers.ResourcePrinter, error) { o.PrintFlags.NamePrintFlags.Operation = operation diff --git a/test/cmd/apply.sh b/test/cmd/apply.sh index 68b6283d4e9..53cfc73c89e 100755 --- a/test/cmd/apply.sh +++ b/test/cmd/apply.sh @@ -101,7 +101,6 @@ run_kubectl_apply_tests() { kube::test::get_object_assert pods "{{range.items}}{{${id_field:?}}}:{{end}}" '' # apply dry-run - kubectl apply --server-dry-run -f hack/testdata/pod.yaml "${kube_flags[@]:?}" kubectl apply --dry-run=true -f hack/testdata/pod.yaml "${kube_flags[@]:?}" kubectl apply --dry-run=client -f hack/testdata/pod.yaml "${kube_flags[@]:?}" kubectl apply --dry-run=server -f hack/testdata/pod.yaml "${kube_flags[@]:?}"