-
Notifications
You must be signed in to change notification settings - Fork 38.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: add namespace autocompletion for kubectl config set-context command #124994
base: master
Are you sure you want to change the base?
fix: add namespace autocompletion for kubectl config set-context command #124994
Conversation
This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the The Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
@ah8ad3 wanna take a look at this? |
I can confirm that it works as expected: $ _output/bin/kubectl config set-context --current --namespace
-- completions --
default kube-node-lease kube-public kube-system |
@@ -79,6 +79,12 @@ func NewCmdConfigSetContext(out io.Writer, configAccess clientcmd.ConfigAccess) | |||
cmd.Flags().Var(&options.cluster, clientcmd.FlagClusterName, clientcmd.FlagClusterName+" for the context entry in kubeconfig") | |||
cmd.Flags().Var(&options.authInfo, clientcmd.FlagAuthInfoName, clientcmd.FlagAuthInfoName+" for the context entry in kubeconfig") | |||
cmd.Flags().Var(&options.namespace, clientcmd.FlagNamespace, clientcmd.FlagNamespace+" for the context entry in kubeconfig") | |||
cmdutil.CheckErr(cmd.RegisterFlagCompletionFunc( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, simplified version would be like in here
ValidArgsFunction: completion.ResourceNameCompletionFunc(f, "pod"), |
ValidArgsFunction: completion.ResourceNameCompletionFunc(f, "namespace"),
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're actually setting:
ValidArgsFunction: completion.ContextCompletionFunc
We can't override it right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that's possible to replace these two, because the added behavior only runs completion for namespace
flag. But i think it's more cleaner IMO to move this section inside ContextCompletionFunc
, this looks good too.
262ef48
to
5a8be05
Compare
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: TessaIO The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Signed-off-by: TessaIO <ahmedgrati1999@gmail.com>
5a8be05
to
53746db
Compare
@ardaguclu thanks for the review! I updated the code and left some replies. |
/retest |
What type of PR is this?
/kind feature
What this PR does / why we need it:
This PR aims to add the namespace autocompletion for kubectl config set-context command
Which issue(s) this PR fixes:
Fixes kubernetes/kubectl#1564
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: