pull/32625/merge
Sylvain Rabot 3 days ago committed by GitHub
commit 88eb90adc6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -152,6 +152,7 @@ func New() *EnvSettings {
func (s *EnvSettings) AddFlags(fs *pflag.FlagSet) {
fs.StringVarP(&s.namespace, "namespace", "n", s.namespace, "namespace scope for this request")
fs.StringVar(&s.KubeConfig, "kubeconfig", "", "path to the kubeconfig file")
fs.StringVar(&s.KubeContext, "context", s.KubeContext, "name of the kubeconfig context to use (alias for --kube-context)")
fs.StringVar(&s.KubeContext, "kube-context", s.KubeContext, "name of the kubeconfig context to use")
fs.StringVar(&s.KubeToken, "kube-token", s.KubeToken, "bearer token used for authentication")
fs.StringVar(&s.KubeAsUser, "kube-as-user", s.KubeAsUser, "username to impersonate for the operation")

@ -233,8 +233,8 @@ func newRootCmdWithConfig(actionConfig *action.Configuration, out io.Writer, arg
log.Fatal(err)
}
// Setup shell completion for the kube-context flag
err = cmd.RegisterFlagCompletionFunc("kube-context", func(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
// Setup shell completion for the kube-context flag (and its --context alias)
kubeContextCompletionFunc := func(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
cobra.CompDebugln("About to get the different kube-contexts", settings.Debug)
loadingRules := clientcmd.NewDefaultClientConfigLoadingRules()
@ -251,7 +251,12 @@ func newRootCmdWithConfig(actionConfig *action.Configuration, out io.Writer, arg
return comps, cobra.ShellCompDirectiveNoFileComp
}
return nil, cobra.ShellCompDirectiveNoFileComp
})
}
err = cmd.RegisterFlagCompletionFunc("kube-context", kubeContextCompletionFunc)
if err != nil {
log.Fatal(err)
}
err = cmd.RegisterFlagCompletionFunc("context", kubeContextCompletionFunc)
if err != nil {
log.Fatal(err)
}

Loading…
Cancel
Save