From f9ab824bc9c0155e582d6df386b1f3af7e6718d3 Mon Sep 17 00:00:00 2001 From: "Julian V. Modesto" Date: Tue, 28 Sep 2021 10:03:20 -0400 Subject: [PATCH] Remove deprecated kubectl --dry-run values. The boolean values for --dry-run have been deprecated for removal since 1.18, more than 2 releases. The default value for --dry-run with the flag set and unspecified has been deprecated for removal since 1.18, more than 2 releases. Both values are now removed in this change. Any kubectl --dry-run usage no longer accepts --dry-run=(true|false) boolean values and usage now requires that a value of (client|server|none) is specified. Kubernetes-commit: e0b7a85ee5b5d546bec2dc0e8cbf5cd4c0c684d8 --- pkg/cmd/util/helpers.go | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/pkg/cmd/util/helpers.go b/pkg/cmd/util/helpers.go index 1d8623540..7b03deb29 100644 --- a/pkg/cmd/util/helpers.go +++ b/pkg/cmd/util/helpers.go @@ -23,7 +23,6 @@ import ( "io" "net/url" "os" - "strconv" "strings" "time" @@ -547,30 +546,18 @@ const ( func GetDryRunStrategy(cmd *cobra.Command) (DryRunStrategy, error) { var dryRunFlag = GetFlagString(cmd, "dry-run") - b, err := strconv.ParseBool(dryRunFlag) - // The flag is not a boolean - if err != nil { - switch dryRunFlag { - case cmd.Flag("dry-run").NoOptDefVal: - klog.Warning(`--dry-run is deprecated and can be replaced with --dry-run=client.`) - return DryRunClient, nil - case "client": - return DryRunClient, nil - case "server": - return DryRunServer, nil - case "none": - return DryRunNone, nil - default: - return DryRunNone, fmt.Errorf(`Invalid dry-run value (%v). Must be "none", "server", or "client".`, dryRunFlag) - } - } - // The flag was a boolean - if b { - klog.Warningf(`--dry-run=%v is deprecated (boolean value) and can be replaced with --dry-run=%s.`, dryRunFlag, "client") + switch dryRunFlag { + case cmd.Flag("dry-run").NoOptDefVal: + return DryRunNone, errors.New(`--dry-run flag without a value was specified. A value must be set: "none", "server", or "client".`) + case "client": return DryRunClient, nil + case "server": + return DryRunServer, nil + case "none": + return DryRunNone, nil + default: + return DryRunNone, fmt.Errorf(`Invalid dry-run value (%v). Must be "none", "server", or "client".`, dryRunFlag) } - klog.Warningf(`--dry-run=%v is deprecated (boolean value) and can be replaced with --dry-run=%s.`, dryRunFlag, "none") - return DryRunNone, nil } // PrintFlagsWithDryRunStrategy sets a success message at print time for the dry run strategy