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:
2fe968deb6/staging/src/k8s.io/kubectl/pkg/cmd/cmd.go (L97)

This fix uses the same defaults for both functions

Signed-off-by: Jonny Langefeld <jonny.langefeld@gmail.com>
This commit is contained in:
Jonny Langefeld 2021-12-19 19:59:46 -08:00
parent 489fb9bee3
commit c4fbd35cf4

View File

@ -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)