diff --git a/pkg/cmd/kind/delete/cluster/deletecluster.go b/pkg/cmd/kind/delete/cluster/deletecluster.go index 3fa98c5be0..05e5059a7f 100644 --- a/pkg/cmd/kind/delete/cluster/deletecluster.go +++ b/pkg/cmd/kind/delete/cluster/deletecluster.go @@ -48,6 +48,7 @@ func NewCommand(logger log.Logger, streams cmd.IOStreams) *cobra.Command { return deleteCluster(logger, flags) }, } + cmd.Flags().StringVarP( &flags.Name, "name", @@ -61,6 +62,19 @@ func NewCommand(logger log.Logger, streams cmd.IOStreams) *cobra.Command { "", "sets kubeconfig path instead of $KUBECONFIG or $HOME/.kube/config", ) + + cobra.CheckErr(cmd.RegisterFlagCompletionFunc("name", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + clusters, err := cluster.NewProvider( + cluster.ProviderWithLogger(logger), + runtime.GetDefault(logger), + ).List() + if err != nil { + return nil, cobra.ShellCompDirectiveError + } + + return clusters, cobra.ShellCompDirectiveNoFileComp + })) + return cmd }