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
Dynamic completion for subcommands that apply to releases #5562
Dynamic completion for subcommands that apply to releases #5562
Conversation
Signed-off-by: Marc Khouzam <marc.khouzam@ville.montreal.qc.ca>
Signed-off-by: Marc Khouzam <marc.khouzam@ville.montreal.qc.ca>
Signed-off-by: Marc Khouzam <marc.khouzam@ville.montreal.qc.ca>
Flags sometimes can be used with an = sign, such as --kube-context=prod. In this case, the variable ${flagname} retains the = sign as part of the flag name. However, in zsh completion, an = sign cannot be part of an index of the associative array 'flaghash' or else it causes an error. This commits strips the = sign out when using ${flagname} as an index. Note that this is not a big deal since flaghash is not actually used anywhere in Helm completion. I believe it is made available by the Cobra framework in case some completions choose to use it. Signed-off-by: Marc Khouzam <marc.khouzam@ville.montreal.qc.ca>
Signed-off-by: Marc Khouzam <marc.khouzam@ville.montreal.qc.ca>
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.
LGTM. And a huge thanks for fixing that all up!
Also, if you'd like to file a second PR against the dev-v3 branch, we'll make sure to get this into Helm 3 as well. You can CC me on that PR |
Sorry for the delay, somehow I never got the notification you had replied! |
@technosophos I was thinking that when doing completion, the list of possible releases should be obtained using 'helm list -a'. Currently this PR does not use the -a' flag. Unless you disagree I will update the PR to use the -a' flag. |
Signed-off-by: Marc Khouzam <marc.khouzam@ville.montreal.qc.ca>
Ok, this one is ready for the master branch. I've just added one commit that uses I'm working on a separate PR for dev-v3. One question: is there a way to list release that start with a specified prefix? Such as I'm asking for two reasons |
Signed-off-by: Marc Khouzam <marc.khouzam@ville.montreal.qc.ca>
While working on the version for dev-v3, I've realized I had forgotten to include This latest commit does this. |
Signed-off-by: Marc Khouzam <marc.khouzam@ville.montreal.qc.ca>
I realized that The real value of this change is when there are more than 256 releases to list. By using the filter, we greatly reduce the chance of the release the user wants being beyond the 256 limit. |
I haven't forgotten about adding this to dev-v3. The issue is that dev-v3 needs a newer version of Cobra for things to work properly. I've reached out to the Cobra project to create a new release, which they've agreed to do. Once it is ready, I'll be able to post this feature for dev-v3. |
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.
LGTM! @marckhouzam do you need to bump cobra to 0.0.4 here as well, or is this good to merge? Let me know :)
3f74a06
to
1bd6281
Compare
@bacongobbler Thanks for the review! I just reverted a commit that was part of this PR because I realized it was a hack for which the real fix is in PR #5680 . As for Cobra, the currently used commit is sufficient for this PR. I think moving to 0.0.4 is a good idea as it brings a couple of minor fixes but should be done independently of this PR. If you want to move to 0.0.4, I can make a new PR for it. Just let me know. So, this PR is good to commit. Thanks! |
Oh, and the force push was because the revert commit did not have the signed-off-by at the end so the DCO check failed. I amended the commit and forced pushed on my branch. |
Awesome! Bumping Cobra would be a good idea to keep Helm 2 and Helm 3 in sync, but if it's not necessary for this PR, we can tackle bumping cobra in a followup PR. Feel free to make a new PR if you'd like :) Thanks for responding so quickly and addressing that commit. This looks good to merge. Thanks so much for following through with this! |
What this PR does / why we need it:
Add dynamic completion after
by fetching the list of releases from the cluster.
Special notes for your reviewer:
This PR puts in the foundation for dynamic completion support in Helm.
It is inspired by the dynamic completion provided by kubectl.
Both bash and zsh are handled.
As dynamic completion actually sends queries to the cluster, this PR handles the use of Helm flags that affect which cluster should be contacted: