From e12816617c5514d1f7bf6778a6f696ffa9a649c0 Mon Sep 17 00:00:00 2001 From: mrrishi Date: Mon, 25 Nov 2024 19:42:23 +0530 Subject: [PATCH 1/2] fix: delete k1dir instead of kubeconfig file --- cmd/reset.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/reset.go b/cmd/reset.go index ca0293cfb..81c1a39f8 100755 --- a/cmd/reset.go +++ b/cmd/reset.go @@ -127,9 +127,9 @@ func runReset() error { return fmt.Errorf("error writing viper config: %w", err) } - if _, err := os.Stat(k1Dir + "/kubeconfig"); !os.IsNotExist(err) { - if err := os.Remove(k1Dir + "/kubeconfig"); err != nil { - return fmt.Errorf("unable to delete %q folder, error: %w", k1Dir+"/kubeconfig", err) + if _, err := os.Stat(k1Dir); !os.IsNotExist(err) { + if err := os.RemoveAll(k1Dir); err != nil { + return fmt.Errorf("unable to delete %q folder, error: %w", k1Dir, err) } } From 490b8784adcd11436fc42270f6a5bd4b95ef9778 Mon Sep 17 00:00:00 2001 From: mrrishi Date: Mon, 25 Nov 2024 23:19:12 +0530 Subject: [PATCH 2/2] remove stat --- cmd/k3d/destroy.go | 6 ++---- cmd/reset.go | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/cmd/k3d/destroy.go b/cmd/k3d/destroy.go index 8fbea220e..0c0af4756 100644 --- a/cmd/k3d/destroy.go +++ b/cmd/k3d/destroy.go @@ -223,10 +223,8 @@ func destroyK3d(_ *cobra.Command, _ []string) error { viper.WriteConfig() } - if _, err := os.Stat(config.K1Dir); !os.IsNotExist(err) { - if err := os.RemoveAll(config.K1Dir); err != nil { - return fmt.Errorf("unable to delete %q: %w", config.K1Dir, err) - } + if err := os.RemoveAll(config.K1Dir); err != nil { + return fmt.Errorf("unable to delete %q: %w", config.K1Dir, err) } time.Sleep(200 * time.Millisecond) fmt.Printf("Your kubefirst platform running in %q has been destroyed.", k3d.CloudProvider) diff --git a/cmd/reset.go b/cmd/reset.go index 81c1a39f8..853afa4a9 100755 --- a/cmd/reset.go +++ b/cmd/reset.go @@ -127,10 +127,8 @@ func runReset() error { return fmt.Errorf("error writing viper config: %w", err) } - if _, err := os.Stat(k1Dir); !os.IsNotExist(err) { - if err := os.RemoveAll(k1Dir); err != nil { - return fmt.Errorf("unable to delete %q folder, error: %w", k1Dir, err) - } + if err := os.RemoveAll(k1Dir); err != nil { + return fmt.Errorf("unable to delete %q folder, error: %w", k1Dir, err) } progressPrinter.IncrementTracker("removing-platform-content")