From 90ee929b883155e240407b9de6e4ec9cd57240ae Mon Sep 17 00:00:00 2001 From: Maciej Szulik Date: Thu, 8 May 2025 14:05:19 +0200 Subject: [PATCH] Drop KUBECTL_ENABLE_CMD_SHADOW featgure gat entirely https://kep.k8s.io/3638 has been promoted to stable back in 1.32 so now is the right time to drop this feature gate entirely. Signed-off-by: Maciej Szulik Kubernetes-commit: d1b5f268b48eda4bb8acdeef52407c27add9e076 --- pkg/cmd/cmd.go | 32 +++++++++++++++----------------- pkg/cmd/util/helpers.go | 1 - 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/pkg/cmd/cmd.go b/pkg/cmd/cmd.go index ccf85a55..42a2c219 100644 --- a/pkg/cmd/cmd.go +++ b/pkg/cmd/cmd.go @@ -143,25 +143,23 @@ func NewDefaultKubectlCommandWithArgs(o KubectlOptions) *cobra.Command { } } } else if err == nil { - if !cmdutil.CmdPluginAsSubcommand.IsDisabled() { - // Command exists(e.g. kubectl create), but it is not certain that - // subcommand also exists (e.g. kubectl create networkpolicy) - // we also have to eliminate kubectl create -f - if IsSubcommandPluginAllowed(foundCmd.Name()) && len(foundArgs) >= 1 && !strings.HasPrefix(foundArgs[0], "-") { - subcommand := foundArgs[0] - builtinSubcmdExist := false - for _, subcmd := range foundCmd.Commands() { - if subcmd.Name() == subcommand { - builtinSubcmdExist = true - break - } + // Command exists(e.g. kubectl create), but it is not certain that + // subcommand also exists (e.g. kubectl create networkpolicy) + // we also have to eliminate kubectl create -f + if IsSubcommandPluginAllowed(foundCmd.Name()) && len(foundArgs) >= 1 && !strings.HasPrefix(foundArgs[0], "-") { + subcommand := foundArgs[0] + builtinSubcmdExist := false + for _, subcmd := range foundCmd.Commands() { + if subcmd.Name() == subcommand { + builtinSubcmdExist = true + break } + } - if !builtinSubcmdExist { - if err := HandlePluginCommand(o.PluginHandler, cmdPathPieces, len(cmdPathPieces)-len(foundArgs)+1); err != nil { - fmt.Fprintf(o.IOStreams.ErrOut, "Error: %v\n", err) - os.Exit(1) - } + if !builtinSubcmdExist { + if err := HandlePluginCommand(o.PluginHandler, cmdPathPieces, len(cmdPathPieces)-len(foundArgs)+1); err != nil { + fmt.Fprintf(o.IOStreams.ErrOut, "Error: %v\n", err) + os.Exit(1) } } } diff --git a/pkg/cmd/util/helpers.go b/pkg/cmd/util/helpers.go index ebee2924..083018c6 100644 --- a/pkg/cmd/util/helpers.go +++ b/pkg/cmd/util/helpers.go @@ -426,7 +426,6 @@ type FeatureGate string const ( ApplySet FeatureGate = "KUBECTL_APPLYSET" - CmdPluginAsSubcommand FeatureGate = "KUBECTL_ENABLE_CMD_SHADOW" OpenAPIV3Patch FeatureGate = "KUBECTL_OPENAPIV3_PATCH" RemoteCommandWebsockets FeatureGate = "KUBECTL_REMOTE_COMMAND_WEBSOCKETS" PortForwardWebsockets FeatureGate = "KUBECTL_PORT_FORWARD_WEBSOCKETS"