Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix terminate #27

Merged
merged 2 commits into from
Nov 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1033,7 +1033,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