Skip to content

Commit

Permalink
fix: remove dive.json on clean command (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyasbhat0 authored Jul 19, 2023
1 parent b05c440 commit 1259c20
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 14 additions & 0 deletions cli/commands/clean/clean.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Copyright © 2023 Hugobyte AI Labs<[email protected]>
package clean

import (
"os"

"github.com/hugobyte/dive/common"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
Expand All @@ -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 !!")
Expand Down
1 change: 0 additions & 1 deletion cli/common/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 1259c20

Please sign in to comment.