From c46b3717291b5ebf764c069208478556dd7a857d Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Thu, 21 Jul 2022 17:19:01 +0000 Subject: [PATCH] cmd/gomote: add -destroy-group flag to destroy For golang/go#53956. Change-Id: I4face246e87af18886b0e7d4c200cca41df5e9ad Reviewed-on: https://go-review.googlesource.com/c/build/+/418787 Run-TryBot: Michael Knyszek Reviewed-by: Carlos Amedee Auto-Submit: Michael Knyszek TryBot-Result: Gopher Robot --- cmd/gomote/destroy.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/cmd/gomote/destroy.go b/cmd/gomote/destroy.go index 86d8cad3c5..7d378641b7 100644 --- a/cmd/gomote/destroy.go +++ b/cmd/gomote/destroy.go @@ -80,6 +80,8 @@ func destroy(args []string) error { } os.Exit(1) } + var destroyGroup bool + fs.BoolVar(&destroyGroup, "destroy-group", false, "if a group is used, destroy the group too") fs.Parse(args) @@ -104,9 +106,15 @@ func destroy(args []string) error { } } if activeGroup != nil { - activeGroup.Instances = nil - if err := storeGroup(activeGroup); err != nil { - return err + if destroyGroup { + if err := deleteGroup(activeGroup.Name); err != nil { + return err + } + } else { + activeGroup.Instances = nil + if err := storeGroup(activeGroup); err != nil { + return err + } } } return nil