Skip to content

Commit

Permalink
Merge pull request #27 from imuqtadir/fix-terminate
Browse files Browse the repository at this point in the history
Fix terminate
  • Loading branch information
bwagner5 authored Nov 20, 2020
2 parents 38533f6 + 591f9ce commit bab6bf8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
9 changes: 3 additions & 6 deletions cmd/terminate.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ func terminateInteractive(h *ec2helper.EC2Helper) {
for {
// Ask instance ID
instanceIdAnswer, err := question.AskInstanceIds(h, instanceIds)
cli.ShowError(err, "Asking instance ID failed")
if cli.ShowError(err, "Terminate Error") {
return
}

if instanceIdAnswer == nil || *instanceIdAnswer == cli.ResponseNo {
break
Expand All @@ -92,11 +94,6 @@ func terminateInteractive(h *ec2helper.EC2Helper) {
}
}

if len(instanceIds) <= 0 {
fmt.Println("No instance available to terminate in this region")
return
}

if question.AskTerminationConfirmation(instanceIds) == cli.ResponseYes {
cli.ShowError(h.TerminateInstances(instanceIds), "Terminating instances failed")
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/question/question.go
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,7 @@ func AskInstanceIds(h *ec2helper.EC2Helper, addedInstanceIds []string) (*string,

// If no instance is available, simply don't ask
if len(data) <= 0 {
return nil, errors.New("No instance available to terminate")
return nil, errors.New("No instance available in selected region for termination")
}

// Add "done" option, if the added instance ids slice is not empty
Expand Down

0 comments on commit bab6bf8

Please sign in to comment.