From c4fbd35cf4bdc76b86dd74e468b69328f5aa20f9 Mon Sep 17 00:00:00 2001 From: Jonny Langefeld Date: Sun, 19 Dec 2021 19:59:46 -0800 Subject: [PATCH] Fix default config flags This is a follow up to #105520 which only changed the new default config flags in the `NewKubectlCommand` function if `kubeConfigFlags == nil`. However they are not nil because they were initialized before here: https://github.com/kubernetes/kubernetes/blob/2fe968deb6cef4feea5bd0eb435e71844e397eed/staging/src/k8s.io/kubectl/pkg/cmd/cmd.go#L97 This fix uses the same defaults for both functions Signed-off-by: Jonny Langefeld --- staging/src/k8s.io/kubectl/pkg/cmd/cmd.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/cmd.go b/staging/src/k8s.io/kubectl/pkg/cmd/cmd.go index 20badf1b330..ffee88841b6 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/cmd.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/cmd.go @@ -89,12 +89,14 @@ type KubectlOptions struct { genericclioptions.IOStreams } +var defaultConfigFlags = genericclioptions.NewConfigFlags(true).WithDeprecatedPasswordFlag().WithDiscoveryBurst(300).WithDiscoveryQPS(50.0) + // NewDefaultKubectlCommand creates the `kubectl` command with default arguments func NewDefaultKubectlCommand() *cobra.Command { return NewDefaultKubectlCommandWithArgs(KubectlOptions{ PluginHandler: NewDefaultPluginHandler(plugin.ValidPluginFilenamePrefixes), Arguments: os.Args, - ConfigFlags: genericclioptions.NewConfigFlags(true).WithDeprecatedPasswordFlag(), + ConfigFlags: defaultConfigFlags, IOStreams: genericclioptions.IOStreams{In: os.Stdin, Out: os.Stdout, ErrOut: os.Stderr}, }) } @@ -294,7 +296,7 @@ func NewKubectlCommand(o KubectlOptions) *cobra.Command { kubeConfigFlags := o.ConfigFlags if kubeConfigFlags == nil { - kubeConfigFlags = genericclioptions.NewConfigFlags(true).WithDeprecatedPasswordFlag().WithDiscoveryBurst(300).WithDiscoveryQPS(50.0) + kubeConfigFlags = defaultConfigFlags } kubeConfigFlags.AddFlags(flags) matchVersionKubeConfigFlags := cmdutil.NewMatchVersionFlags(kubeConfigFlags)