diff --git a/cli/commands/clean/clean.go b/cli/commands/clean/clean.go index e38d84cb..a19ad650 100644 --- a/cli/commands/clean/clean.go +++ b/cli/commands/clean/clean.go @@ -4,6 +4,8 @@ Copyright © 2023 Hugobyte AI Labs package clean import ( + "os" + "github.com/hugobyte/dive/common" "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -17,6 +19,18 @@ func NewCleanCmd(diveContext *common.DiveContext) *cobra.Command { Long: `Destroys and removes any running encalves. If no enclaves running to remove it will throw an error`, Run: func(cmd *cobra.Command, args []string) { common.ValidateCmdArgs(args, cmd.UsageString()) + pwd, err := os.Getwd() + + if err != nil { + diveContext.FatalError("Failed cleaning with error: %v", err.Error()) + } + + _, err = os.Stat(pwd + "/dive.json") + + if err == nil { + os.Remove(pwd + "/dive.json") + } + enclaveName := diveContext.GetEnclaves() if enclaveName == "" { logrus.Errorf("No enclaves running to clean !!") diff --git a/cli/common/types.go b/cli/common/types.go index ce5e5cdb..0656729d 100644 --- a/cli/common/types.go +++ b/cli/common/types.go @@ -197,7 +197,6 @@ func (diveContext *DiveContext) GetEnclaves() string { func (diveContext *DiveContext) Clean() { diveContext.log.Info("Successfully connected to kurtosis engine...") diveContext.log.Info("Initializing cleaning process...") - // shouldCleanAll set to true as default for beta release. enclaves, err := diveContext.KurtosisContext.Clean(diveContext.Ctx, true) if err != nil {