From f3b11e1d6d7c7da749c7be6514bb023d97331036 Mon Sep 17 00:00:00 2001 From: kuritka Date: Fri, 10 Dec 2021 14:51:49 +0100 Subject: [PATCH] Removing non-existing cluster via configuration Signed-off-by: kuritka --- cmd/cluster/clusterDelete.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/cluster/clusterDelete.go b/cmd/cluster/clusterDelete.go index cd552d8c0..75238be2b 100644 --- a/cmd/cluster/clusterDelete.go +++ b/cmd/cluster/clusterDelete.go @@ -22,6 +22,7 @@ THE SOFTWARE. package cluster import ( + "errors" "fmt" "os" "path" @@ -131,8 +132,9 @@ func parseDeleteClusterCmd(cmd *cobra.Command, args []string) []*k3d.Cluster { } c, err := client.ClusterGet(cmd.Context(), runtimes.SelectedRuntime, &k3d.Cluster{Name: clusterDeleteCfgViper.GetString("name")}) - if err != nil { - l.Log().Fatalf("failed to delete cluster '%s': %v", clusterDeleteCfgViper.GetString("name"), err) + if errors.Is(err, client.ClusterGetNoNodesFoundError) { + l.Log().Infof("No nodes found for cluster '%s', nothing to delete.", clusterDeleteCfgViper.GetString("name")) + return nil } clusters = append(clusters, c)