Skip to content

Commit

Permalink
Merge pull request #2328 from konstructio/fix-reset
Browse files Browse the repository at this point in the history
fix: delete k1dir instead of kubeconfig file
  • Loading branch information
jokestax authored Nov 25, 2024
2 parents 9344ad8 + 490b878 commit 47e076e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 2 additions & 4 deletions cmd/k3d/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 2 additions & 4 deletions cmd/reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,8 @@ 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.RemoveAll(k1Dir); err != nil {
return fmt.Errorf("unable to delete %q folder, error: %w", k1Dir, err)
}

progressPrinter.IncrementTracker("removing-platform-content")
Expand Down

0 comments on commit 47e076e

Please sign in to comment.