-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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: delete cluster flag completion #3166
base: main
Are you sure you want to change the base?
feat: delete cluster flag completion #3166
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.
Needs 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. 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. |
@@ -48,9 +48,14 @@ func NewCommand(logger log.Logger, streams cmd.IOStreams) *cobra.Command { | |||
return deleteCluster(logger, flags) | |||
}, | |||
} | |||
|
|||
var ( | |||
name = "name" |
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.
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.
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.
Thanks. Updated.
|
||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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.
sorry, i missed that my review comments were left in pending state
@@ -48,9 +48,14 @@ func NewCommand(logger log.Logger, streams cmd.IOStreams) *cobra.Command { | |||
return deleteCluster(logger, flags) | |||
}, | |||
} | |||
|
|||
const ( | |||
nameFlag = "name" |
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 still don't think this is more descriptive that "name"
which is only used in two places anyhow ...
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.
+1
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.
Agreed. Done
|
||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
#3163
Preview: