Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: delete kubefirst file when doing kubefirst reset - KRA-73 #2344

Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion cmd/reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ See the LICENSE file for more details.
package cmd

import (
"errors"
"fmt"
"os"
"strconv"
Expand Down Expand Up @@ -107,6 +108,7 @@ func runReset() error {
return fmt.Errorf("unable to get user home directory: %w", err)
}
k1Dir := fmt.Sprintf("%s/.k1", homePath)
kubefirstConfig := fmt.Sprintf("%s/.kubefirst", homePath)

if err := utils.ResetK1Dir(k1Dir); err != nil {
return fmt.Errorf("error resetting k1 directory: %w", err)
Expand All @@ -131,9 +133,18 @@ func runReset() error {
return fmt.Errorf("unable to delete %q folder, error: %w", k1Dir, err)
}

if _, err := os.Stat(kubefirstConfig); err != nil {
if errors.Is(err, os.ErrNotExist) {
log.Info().Msgf("%q does not exist, continuing", kubefirstConfig)
} else {
return fmt.Errorf("error checking %q: %w", kubefirstConfig, err)
}
} else if err := os.Remove(kubefirstConfig); err != nil {
return fmt.Errorf("unable to remove %q, error: %w", kubefirstConfig, err)
}

progressPrinter.IncrementTracker("removing-platform-content")
time.Sleep(time.Second * 2)
progress.Progress.Quit()

return nil
}
Loading