Skip to content

Commit

Permalink
cmd/gomote: make "create" create a new group from GOMOTE_GROUP
Browse files Browse the repository at this point in the history
For golang/go#53956.

Change-Id: I14b2e094f7c21cab3a08d73911e73644e22d0d7b
Reviewed-on: https://go-review.googlesource.com/c/build/+/418788
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
  • Loading branch information
mknyszek authored and gopherbot committed Nov 18, 2022
1 parent 365723c commit 08589fd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cmd/gomote/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ func create(args []string) error {

fs.Usage = func() {
fmt.Fprintln(os.Stderr, "create usage: gomote create [create-opts] <type>")
fmt.Fprintln(os.Stderr)
fmt.Fprintln(os.Stderr, "If there's a valid group specified, new instances are")
fmt.Fprintln(os.Stderr, "automatically added to the group. If the group in")
fmt.Fprintln(os.Stderr, "$GOMOTE_GROUP doesn't exist, and there's no other group")
fmt.Fprintln(os.Stderr, "specified, it will be created and new instances will be")
fmt.Fprintln(os.Stderr, "added to that group.")
fs.PrintDefaults()
fmt.Fprintln(os.Stderr, "\nValid types:")
for _, bt := range builders() {
Expand Down Expand Up @@ -183,6 +189,12 @@ func create(args []string) error {
return err
}
}
if group == nil && os.Getenv("GOMOTE_GROUP") != "" {
group, err = doCreateGroup(os.Getenv("GOMOTE_GROUP"))
if err != nil {
return err
}
}

var tmpOutDir string
var tmpOutDirOnce sync.Once
Expand Down
1 change: 1 addition & 0 deletions cmd/gomote/gomote.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ func main() {
if err == nil {
fmt.Fprintf(os.Stderr, "# Using group %q from GOMOTE_GROUP\n", *groupName)
}
// Note that an invalid group in GOMOTE_GROUP is OK.
}
}

Expand Down

0 comments on commit 08589fd

Please sign in to comment.