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.
This commit is contained in:
Julian V. Modesto 2020-05-20 16:53:53 -04:00
parent eb34058777
commit 3e93f99262
2 changed files with 0 additions and 13 deletions

View File

@ -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().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 <group/version/kind> for --prune") cmd.Flags().StringArrayVar(&o.PruneWhitelist, "prune-whitelist", o.PruneWhitelist, "Overwrite the default whitelist with <group/version/kind> 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().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.AddDryRunFlag(cmd)
cmdutil.AddServerSideApplyFlags(cmd) cmdutil.AddServerSideApplyFlags(cmd)
cmdutil.AddFieldManagerFlagVar(cmd, &o.FieldManager, FieldManagerClientSideApply) 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?)") 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 // allow for a success message operation to be specified at print time
o.ToPrinter = func(operation string) (printers.ResourcePrinter, error) { o.ToPrinter = func(operation string) (printers.ResourcePrinter, error) {
o.PrintFlags.NamePrintFlags.Operation = operation o.PrintFlags.NamePrintFlags.Operation = operation

View File

@ -101,7 +101,6 @@ run_kubectl_apply_tests() {
kube::test::get_object_assert pods "{{range.items}}{{${id_field:?}}}:{{end}}" '' kube::test::get_object_assert pods "{{range.items}}{{${id_field:?}}}:{{end}}" ''
# apply dry-run # 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=true -f hack/testdata/pod.yaml "${kube_flags[@]:?}"
kubectl apply --dry-run=client -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[@]:?}" kubectl apply --dry-run=server -f hack/testdata/pod.yaml "${kube_flags[@]:?}"