-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
⚠️ clusterctl completion zsh: Use native zsh completion #4113
⚠️ clusterctl completion zsh: Use native zsh completion #4113
Conversation
Hi @superbrothers. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
/assign Thanks for this PR. I can review this to check functionality. |
echo "autoload -U compinit; compinit" >> ~/.zshrc | ||
|
||
# To load completions for each session, execute once: | ||
clusterctl completion zsh > "${fpath[1]}/_clusterctl" |
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 am getting a permission error when running this command,
zsh: permission denied: /usr/local/share/zsh/site-functions/_clusterctl
Not sure if only it is system-specific.
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.
It depends on the system.
2a2c89d
to
a7314ca
Compare
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.
@superbrothers Thanks for this update! I haven't been able to test the zsh completion but it mostly lgtm just some nits and clarifications regarding some files.
Due to this change, we will not able to load the zsh completion code with the following method: ``` source <(clusterctl completion zsh) ``` Instead, we execute the following command once: ``` clusterctl completion zsh >"${fpath[1]}/_clusterctl" ``` Then we need to start a new shell for this setup to take effect. --- In addition, github.com/spf13/cobra is updated to v1.1.1 in order to use native zsh completion feature.
5f1e6eb
to
8d75200
Compare
/ok-to-test |
Works for me! /lgtm |
/lgtm |
Just one question: why is the change marked as breaking |
@CecileRobertMichon It seems that the loading of the zsh logic (from the changes in the docs) has changed a bit. |
Ok, just wanted to make sure there wasn't another breaking change I had missed /approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: CecileRobertMichon, wfernandes The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/test pull-cluster-api-test-main |
Zsh recommends putting the completion file on It is however possible to support sourcing if you feel it is better for your users. To do that you have to add the line |
@marckhouzam We have this in our documentation https://master.cluster-api.sigs.k8s.io/clusterctl/commands/completion.html#zsh which seems like it adds it to the fpath. Also the output of So I guess this isn't a breaking change. Yay! |
Well, it tells users to add it themselves 😁. This is great and may be what you prefer to stick with. I just wanted to mention there is a way to enable sourcing of you feel it is important.
I believe the first line starts with a But I'm not arguing in favor, I just wanted to inform as it is something that has come up a couple of times in Cobra Issues. |
This is a nice technique. We should use this technique to avoid a "breaking change". |
What this PR does / why we need it:
ref/ #4090
Due to this change, we will not able to load the zsh completion code
with the following method:
Instead, we execute the following command once:
Then we need to start a new shell for this setup to take effect.
In addition, github.com/spf13/cobra is updated to v1.1.1 in order to use
native zsh completion feature.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Closes #4090