From 78e78be9cde4657d5ab78ecdd723a1ad9f36ce14 Mon Sep 17 00:00:00 2001 From: Mohammed Date: Thu, 19 Nov 2020 14:45:46 -0600 Subject: [PATCH 1/2] Avoid showing multiple errors when no instance available --- cmd/terminate.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/cmd/terminate.go b/cmd/terminate.go index 206c771..5a6bf2c 100644 --- a/cmd/terminate.go +++ b/cmd/terminate.go @@ -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 @@ -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") } From 591f9ce5bbb2709a940e0cef55ef72432de15936 Mon Sep 17 00:00:00 2001 From: Mohammed Date: Thu, 19 Nov 2020 14:52:09 -0600 Subject: [PATCH 2/2] update messaging for terminate --- pkg/question/question.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/question/question.go b/pkg/question/question.go index 6801331..8621f30 100644 --- a/pkg/question/question.go +++ b/pkg/question/question.go @@ -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