@@ -164,6 +164,8 @@ func create(args []string) error {
164
164
fs .IntVar (& count , "count" , 1 , "number of instances to create" )
165
165
var setup bool
166
166
fs .BoolVar (& setup , "setup" , false , "set up the instance by pushing GOROOT and building the Go toolchain" )
167
+ var newGroup string
168
+ fs .StringVar (& newGroup , "new-group" , "" , "also create a new group and add the new instances to it" )
167
169
168
170
fs .Parse (args )
169
171
if fs .NArg () != 1 {
@@ -180,7 +182,15 @@ func create(args []string) error {
180
182
}
181
183
}
182
184
183
- var activeGroupMu sync.Mutex
185
+ var groupMu sync.Mutex
186
+ group := activeGroup
187
+ if newGroup != "" {
188
+ group , err = doCreateGroup (newGroup )
189
+ if err != nil {
190
+ return err
191
+ }
192
+ }
193
+
184
194
eg , ctx := errgroup .WithContext (context .Background ())
185
195
client := gomoteServerClient (ctx )
186
196
for i := 0 ; i < count ; i ++ {
@@ -207,10 +217,10 @@ func create(args []string) error {
207
217
}
208
218
}
209
219
fmt .Println (inst )
210
- if activeGroup != nil {
211
- activeGroupMu .Lock ()
212
- activeGroup .Instances = append (activeGroup .Instances , inst )
213
- activeGroupMu .Unlock ()
220
+ if group != nil {
221
+ groupMu .Lock ()
222
+ group .Instances = append (group .Instances , inst )
223
+ groupMu .Unlock ()
214
224
}
215
225
if ! setup {
216
226
return nil
@@ -239,8 +249,8 @@ func create(args []string) error {
239
249
if err := eg .Wait (); err != nil {
240
250
return err
241
251
}
242
- if activeGroup != nil {
243
- return storeGroup (activeGroup )
252
+ if group != nil {
253
+ return storeGroup (group )
244
254
}
245
255
return nil
246
256
}
0 commit comments