Skip to content

Commit

Permalink
don't allow edit in destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
bonifaido committed May 24, 2019
1 parent cb7a938 commit 569771c
Showing 1 changed file with 9 additions and 22 deletions.
31 changes: 9 additions & 22 deletions internal/cli/command/controlplane/down.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,38 +87,25 @@ func runDestroy(banzaiCli cli.Cli, options createOptions) {
}
}

for {
if bytes, err := json.MarshalIndent(out, "", " "); err != nil {
log.Errorf("failed to marshal descriptor: %v", err)
log.Debugf("descriptor: %#v", out)
} else {
content = string(bytes)
_, _ = fmt.Fprintf(os.Stderr, "The current state of the descriptor:\n\n%s\n", content)
}

var open bool
_ = survey.AskOne(&survey.Confirm{Message: "Do you want to edit the controlplane descriptor in your text editor?"}, &open, nil)
if !open {
break
}

_ = survey.AskOne(&survey.Editor{Message: "controlplane descriptor:", Default: content, HideDefault: true, AppendDefault: true}, &content, nil)
if err := json.Unmarshal([]byte(content), &out); err != nil {
log.Errorf("can't parse descriptor: %v", err)
}
if bytes, err := json.MarshalIndent(out, "", " "); err != nil {
log.Debugf("descriptor: %#v", out)
log.Fatalf("failed to marshal descriptor: %v", err)
} else {
content = string(bytes)
_, _ = fmt.Fprintf(os.Stderr, "The current state of the descriptor:\n\n%s\n", content)
}

var create bool
var destroy bool
_ = survey.AskOne(
&survey.Confirm{
Message: "Do you want to DESTROY the controlplane now?",
Default: true,
},
&create,
&destroy,
nil,
)

if !create {
if !destroy {
log.Fatal("controlplane destroy cancelled")
}
} else { // non-interactive
Expand Down

0 comments on commit 569771c

Please sign in to comment.