-
Notifications
You must be signed in to change notification settings - Fork 39.8k
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
Implement custom completions for some flags using Go #93714
Conversation
/cc @brianpursley @marckhouzam PTAL. You might be only interested in this commit: 58e57ee |
@knight42 how are things going for these Go completions? |
@marckhouzam Oh I think I have missed the comments from @brianpursley and just waiting for review. I am still working on it. |
5f3790a
to
7269c7d
Compare
@@ -0,0 +1,90 @@ | |||
/* |
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.
For reviewer: I move helper functions here as I think they might be reused for the completion of kubectl config get-{contexts,clusters}
36bf7fd
to
3b29a23
Compare
@knight42: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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/test-infra repository. I understand the commands that are listed here. |
Only --context, --cluster, --user and --namespace are included. Signed-off-by: knight42 <[email protected]>
3b29a23
to
3df31ca
Compare
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: knight42 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 |
@knight42 any update on this? I think this is a good start, but what else would need to be implemented in order to get rid of the custom bash and zsh code in these two locations?
I think below is the key function. It looks like there are 7 completion cases that need to be implemented and then we could get rid of the above two blocks of code I linked to...
Types of completions:
|
@brianpursley The original target of this PR is to only implement custom completions using Go for flag --context, --cluster, --user and --namespace. I think it is completed now.
We need to modify each command as described in https://github.com/spf13/cobra/blob/master/shell_completions.md#dynamic-completion-of-nouns. I plan to open separate PR for each command, perhaps we could open a tracking issue and call for community participation. |
I feel this would have value to merge as is. It will work for both bash and zsh and is a step in the right direction to get rid of the custom bash code. And it will work automatically for fish completion if/when it is added (#92989) |
I'm not trying to be difficult, but I am hesitant to merge this because it does not fully address the issue. I don't really like the idea of having some of the completions in go, but others still using custom scripts. I was hoping to see a PR that fully addresses the issue. However, if someone with the ability to approve PRs is comfortable with doing it though, then I will go along with their opinion on this, as I don't want to make this a sticking point if everyone else sees things differently. Either way, we need to make 100% sure this doesn't break existing completions for zsh and bash. This probably needs some manual confirmation as I don't think we have a way to test completions using integration tests. Also, when go completions are created, we should be able to have go unit tests for those now, so that might help too. My number one concern is not to break existing completions which I know tool a long time and a lot of work to get working satisfactorily. |
@brianpursley I agree with your concerns about making sure this doesn't break anything. That is why I personally like the gradual approach so as to make sure each change is safe. That being said, you are also right that temporarily having half the completions in go and the other half in bash will still cause some confusion. @knight42 are you hoping to continue this work for the rest of the custom completions? I would like to help but I worry that my total lack of knowledge of the kubectl code base will prevent me from suggesting the correct go code for the completions. |
@brianpursley I've built upon @knight42 work and removed all bash scripting in #96087. |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
@knight42: PR needs rebase. 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/test-infra repository. |
/close |
What type of PR is this?
/kind feature
What this PR does / why we need it:
Implement custom completions using Go for flag
--context
,--cluster
,--user
and--namespace
.Which issue(s) this PR fixes:
Part of kubernetes/kubectl#882
Special notes for your reviewer:
Test the new completion code
Please note that the new completion code requires the new kubectl.
Does this PR introduce a user-facing change?:
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: