Skip to content

Commit

Permalink
chore: check for existence of the .kubefirst file before trying to re…
Browse files Browse the repository at this point in the history
…move it

Signed-off-by: nathan-nicholson <[email protected]>
  • Loading branch information
nathan-nicholson committed Dec 10, 2024
1 parent 69e5168 commit 815d71a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions 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 @@ -132,13 +133,18 @@ func runReset() error {
return fmt.Errorf("unable to delete %q folder, error: %w", k1Dir, err)
}

if err := os.Remove(kubefirstConfig); err != nil {
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
}

0 comments on commit 815d71a

Please sign in to comment.