feat: delete cluster flag completion#3166
feat: delete cluster flag completion#3166iyear wants to merge 2 commits intokubernetes-sigs:mainfrom
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: iyear The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Welcome @iyear! |
|
Hi @iyear. 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. DetailsInstructions 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. |
| } | ||
|
|
||
| var ( | ||
| name = "name" |
There was a problem hiding this comment.
Nit: This should be a const not a var and it should have a more descriptive name or else just explicitly paste "name" into each location. It's not really clearer to have `const name = "name" and it's strictly worse to have it as a var.
|
|
||
| cobra.CheckErr(cmd.RegisterFlagCompletionFunc(name, func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { | ||
| clusters, err := cluster.NewProvider( | ||
| cluster.ProviderWithLogger(logger), |
There was a problem hiding this comment.
What happens when podman support is stable and we move from KIND_EXPERIMENTAL_PROVIDER to KIND_PROVIDER as a default for a --provider flag? Can flag completion check for other flag values?
This feature seems like it may unfortunately be at least as problematic to maintain as it is useful.
Using KIND_CLUSTER_NAME is another option to get around repeatedly typing these.
There was a problem hiding this comment.
What happens when podman support is stable and we move from KIND_EXPERIMENTAL_PROVIDER to KIND_PROVIDER as a default for a --provider flag?
Does this mean that the implementation of kind get clusters will change? The code in PR is copied from get clusters
Can flag completion check for other flag values?
Yes it can.
or extract get clusters as a common function, and we pass in the existing args and flags then get results.
There was a problem hiding this comment.
Does this mean that the implementation of kind get clusters will change? The code in PR is copied from get clusters
Yes. It's defaulting based on availability or the env currently.
There was a problem hiding this comment.
And how about extract kind get clusters runE as a common function ? IMO, the completion is like an alias of get clusters.
There was a problem hiding this comment.
Sure, I've just never used a tool where one flag completed based on another flag and didn't know if cobra can support this. If it can then let's go ahead :-)
3a12be2 to
2b04d6d
Compare
BenTheElder
left a comment
There was a problem hiding this comment.
sorry, i missed that my review comments were left in pending state
| } | ||
|
|
||
| const ( | ||
| nameFlag = "name" |
There was a problem hiding this comment.
I still don't think this is more descriptive that "name" which is only used in two places anyhow ...
|
|
||
| cobra.CheckErr(cmd.RegisterFlagCompletionFunc(name, func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { | ||
| clusters, err := cluster.NewProvider( | ||
| cluster.ProviderWithLogger(logger), |
There was a problem hiding this comment.
Does this mean that the implementation of kind get clusters will change? The code in PR is copied from get clusters
Yes. It's defaulting based on availability or the env currently.
|
This looks reasonable. Completion would be useful here. /lgtm |
|
cc @aojea, need another pair of eyes on this. trying this year to get through the backlog of things that fell through the cracks 😅 |
|
@aojea @BenTheElder reminder on this. I think it would be good to either get this through, or decide we aren't going to do it. I do think it's useful though, so it would be a nice usability improvement. |
#3163
Preview: