|
|
|
@ -41,10 +41,10 @@ func NewCmdDeleteCluster() *cobra.Command { |
|
|
|
|
|
|
|
|
|
// create new cobra command
|
|
|
|
|
cmd := &cobra.Command{ |
|
|
|
|
Use: "cluster (NAME | --all)", |
|
|
|
|
Short: "Delete a cluster.", |
|
|
|
|
Long: `Delete a cluster.`, |
|
|
|
|
Args: cobra.MinimumNArgs(0), // 0 or n arguments; 0 only if --all is set
|
|
|
|
|
Use: "cluster [NAME [NAME ...] | --all]", |
|
|
|
|
Short: "Delete cluster(s).", |
|
|
|
|
Long: `Delete cluster(s).`, |
|
|
|
|
Args: cobra.MinimumNArgs(0), // 0 or n arguments; 0 = default cluster name
|
|
|
|
|
ValidArgsFunction: util.ValidArgsAvailableClusters, |
|
|
|
|
Run: func(cmd *cobra.Command, args []string) { |
|
|
|
|
clusters := parseDeleteClusterCmd(cmd, args) |
|
|
|
@ -106,11 +106,12 @@ func parseDeleteClusterCmd(cmd *cobra.Command, args []string) []*k3d.Cluster { |
|
|
|
|
return clusters |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if len(args) < 1 { |
|
|
|
|
log.Fatalln("Expecting at least one cluster name if `--all` is not set") |
|
|
|
|
clusternames := []string{k3d.DefaultClusterName} |
|
|
|
|
if len(args) != 0 { |
|
|
|
|
clusternames = args |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for _, name := range args { |
|
|
|
|
for _, name := range clusternames { |
|
|
|
|
cluster, err := cluster.GetCluster(cmd.Context(), runtimes.SelectedRuntime, &k3d.Cluster{Name: name}) |
|
|
|
|
if err != nil { |
|
|
|
|
log.Fatalln(err) |
|
|
|
|