-
Notifications
You must be signed in to change notification settings - Fork 880
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
feat(cli): dynamic shell completion for main resources names (rollouts, experiments, analysisrun) #2379
feat(cli): dynamic shell completion for main resources names (rollouts, experiments, analysisrun) #2379
Conversation
I am maybe missing what exactly this would get us. I am a fish user and things seem to also be working as I would expect with the first completion you added in your WIP PR so I think it would be ok to not do this as well.
Yes for fish this make sense to leave on and I think it is generally expected and nice as far as bash I am also impartial as a non bash user, I am fine leaving it to false and seeing if a request comes in later to change etc.
I took a quick look at the kubectl testing and this would also work well here. With some of the stances within ArgoProj coming up around PR acceptance criteria having unit tests would be ideal as well. Also thank you for contributing and working on this feature it will be really nice to have! |
The cobra spec I could find is unclear: maybe it's mandatory we do the filtering in go. But it doesn't seem to be the case, thanks to your fish test. In fact, after reading more in the kubectl PR, I did implement the filter in go.
=> good for me
It will take me more time to complete that, I'm not sure I can finish before the end of hacktoberfest. |
d36dcda
to
6e21e7e
Compare
Codecov ReportBase: 82.76% // Head: 82.76% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #2379 +/- ##
=======================================
Coverage 82.76% 82.76%
=======================================
Files 121 122 +1
Lines 18536 18590 +54
=======================================
+ Hits 15341 15386 +45
- Misses 2410 2416 +6
- Partials 785 788 +3
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
d23eb22
to
d3f9fd3
Compare
Current state:
|
I think doing a dynamic completion for a restricted subset of the commands with tests would be prefered for hacktoberfest. Even if you don't finish the PR 100% completely but it is close I don't mind adding the label to it if you need a bit more time to finish up after as well.
I think this is a good location for this package |
I started looking into the tests (I'm thinking about reusing |
I've pushed unit tests, directly in the new
|
I've completed the PR description: the PR is ready for review from my PoV. |
Could you please try to just trigger tests again with a command something like |
I actually think the e2e errors are because of not pinning a k8s version in e2e tests, I will work on getting that fixed. |
when working on the multi k8s version e2e tests PR (#2380) I also have some tests failing, but different ones, and only on k8s 1.23 (not sure if those are hard or flaky tests..) |
There are quite a bit of flaky tests but they do retry, I got the multi k8s versions PR merged can you trigger a retest on this PR |
…TAB]' works toward argoproj#2015 use ValidArgsFunction from cobra to list candidates for completion: https://github.com/spf13/cobra/blob/main/shell_completions.md#dynamic-completion-of-nouns use v2 of GenBashCompletion from cobra: https://github.com/spf13/cobra/blob/main/shell_completions.md#bash-completion-v2 - I chose to disable descriptions for completion (as a bash user I'm not used to that), but it's enabled for fish it seems, we can enable it if desired, I have no strong opinion on it Signed-off-by: Thomas Riccardi <[email protected]>
Signed-off-by: Thomas Riccardi <[email protected]>
...accoding to the Cobra auto-generated CLI documentation. Signed-off-by: Thomas Riccardi <[email protected]>
...accoding to the Cobra auto-generated CLI documentation. Signed-off-by: Thomas Riccardi <[email protected]>
...accoding to the Cobra auto-generated CLI documentation. Signed-off-by: Thomas Riccardi <[email protected]>
Signed-off-by: Thomas Riccardi <[email protected]>
- inspired from kubectl own completion package tests - fake cmd to avoid circular import - reuse info/testdata but we could build our own data for more isolated tests if needed - test all 3 types (Rollout, Experiment, AnalysisRun) - test both first argument completion and second argument Signed-off-by: Thomas Riccardi <[email protected]>
Like in kubectl own completion tests, we now have an independent 'completion' package with its own tests. Stop testing in cmd/ callers packages. This reverts commit 75eb5ae. Signed-off-by: Thomas Riccardi <[email protected]>
0725ee5
to
17851c8
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
…s, experiments, analysisrun) (argoproj#2379) * PoC dynamic shell completion for 'kubectl-argo-rollouts get rollout [TAB]' works toward argoproj#2015 use ValidArgsFunction from cobra to list candidates for completion: https://github.com/spf13/cobra/blob/main/shell_completions.md#dynamic-completion-of-nouns use v2 of GenBashCompletion from cobra: https://github.com/spf13/cobra/blob/main/shell_completions.md#bash-completion-v2 - I chose to disable descriptions for completion (as a bash user I'm not used to that), but it's enabled for fish it seems, we can enable it if desired, I have no strong opinion on it Signed-off-by: Thomas Riccardi <[email protected]> * Factorize resource names completion functions in new util/completion Signed-off-by: Thomas Riccardi <[email protected]> * Add dynamic auto-completion to all ROLLOUT_NAME locations in CLI ...accoding to the Cobra auto-generated CLI documentation. Signed-off-by: Thomas Riccardi <[email protected]> * Add dynamic auto-completion to all EXPERIMENT_NAME locations in CLI ...accoding to the Cobra auto-generated CLI documentation. Signed-off-by: Thomas Riccardi <[email protected]> * Add dynamic auto-completion to all ANALYSISRUN_NAME locations in CLI ...accoding to the Cobra auto-generated CLI documentation. Signed-off-by: Thomas Riccardi <[email protected]> * WIP unit-test dynamic completion Signed-off-by: Thomas Riccardi <[email protected]> * Add unit-tests for new completion package - inspired from kubectl own completion package tests - fake cmd to avoid circular import - reuse info/testdata but we could build our own data for more isolated tests if needed - test all 3 types (Rollout, Experiment, AnalysisRun) - test both first argument completion and second argument Signed-off-by: Thomas Riccardi <[email protected]> * Revert "WIP unit-test dynamic completion" Like in kubectl own completion tests, we now have an independent 'completion' package with its own tests. Stop testing in cmd/ callers packages. This reverts commit 75eb5ae. Signed-off-by: Thomas Riccardi <[email protected]> Signed-off-by: Thomas Riccardi <[email protected]>
…s, experiments, analysisrun) (argoproj#2379) * PoC dynamic shell completion for 'kubectl-argo-rollouts get rollout [TAB]' works toward argoproj#2015 use ValidArgsFunction from cobra to list candidates for completion: https://github.com/spf13/cobra/blob/main/shell_completions.md#dynamic-completion-of-nouns use v2 of GenBashCompletion from cobra: https://github.com/spf13/cobra/blob/main/shell_completions.md#bash-completion-v2 - I chose to disable descriptions for completion (as a bash user I'm not used to that), but it's enabled for fish it seems, we can enable it if desired, I have no strong opinion on it Signed-off-by: Thomas Riccardi <[email protected]> * Factorize resource names completion functions in new util/completion Signed-off-by: Thomas Riccardi <[email protected]> * Add dynamic auto-completion to all ROLLOUT_NAME locations in CLI ...accoding to the Cobra auto-generated CLI documentation. Signed-off-by: Thomas Riccardi <[email protected]> * Add dynamic auto-completion to all EXPERIMENT_NAME locations in CLI ...accoding to the Cobra auto-generated CLI documentation. Signed-off-by: Thomas Riccardi <[email protected]> * Add dynamic auto-completion to all ANALYSISRUN_NAME locations in CLI ...accoding to the Cobra auto-generated CLI documentation. Signed-off-by: Thomas Riccardi <[email protected]> * WIP unit-test dynamic completion Signed-off-by: Thomas Riccardi <[email protected]> * Add unit-tests for new completion package - inspired from kubectl own completion package tests - fake cmd to avoid circular import - reuse info/testdata but we could build our own data for more isolated tests if needed - test all 3 types (Rollout, Experiment, AnalysisRun) - test both first argument completion and second argument Signed-off-by: Thomas Riccardi <[email protected]> * Revert "WIP unit-test dynamic completion" Like in kubectl own completion tests, we now have an independent 'completion' package with its own tests. Stop testing in cmd/ callers packages. This reverts commit 75eb5ae. Signed-off-by: Thomas Riccardi <[email protected]> Signed-off-by: Thomas Riccardi <[email protected]>
MVP for #2015
Add dynamic shell completion for all commands that take a ROLLOUT_NAME, EXPERIMENT_NAME, ANALYSISRUN_NAME argument.
Implementation details
Inspired from what was done in
kubectl
when they migrated to go completion kubernetes/kubernetes#96087, as well as a later refactor (kubernetes/kubernetes@c4f8c57).pkg/kubectl-argo-rollouts/util/completion
, with its own testsUse
strings are not all correct)Use
strings are not showing when the command supports multiple resources, at least forabort
: for now only the first resource name is completed; I could support more but we should probably start by documenting those cases in theUse
and maybeShort
?kubectl-argo-rollouts __complete lint ""
:Completion ended with directive: ShellCompDirectiveDefault
): I don't know if we can disable it by default or if we need to add it everywhere.create -f
orlint -f
set image
second arg:CONTAINER=IMAGE
for nowChecklist:
"fix(controller): Updates such and such. Fixes #1234"
.