@@ -148,6 +148,7 @@ func createEnvCmd(user *string) *cobra.Command {
148
148
img string
149
149
tag string
150
150
follow bool
151
+ useCVM bool
151
152
)
152
153
153
154
cmd := & cobra.Command {
@@ -189,13 +190,14 @@ coder envs create my-new-powerful-env --cpu 12 --disk 100 --memory 16 --image ub
189
190
190
191
// ExactArgs(1) ensures our name value can't panic on an out of bounds.
191
192
createReq := & coder.CreateEnvironmentRequest {
192
- Name : args [0 ],
193
- ImageID : importedImg .ID ,
194
- ImageTag : tag ,
195
- CPUCores : cpu ,
196
- MemoryGB : memory ,
197
- DiskGB : disk ,
198
- GPUs : gpus ,
193
+ Name : args [0 ],
194
+ ImageID : importedImg .ID ,
195
+ ImageTag : tag ,
196
+ CPUCores : cpu ,
197
+ MemoryGB : memory ,
198
+ DiskGB : disk ,
199
+ GPUs : gpus ,
200
+ UseContainerVM : useCVM ,
199
201
}
200
202
201
203
// if any of these defaulted to their zero value we provision
@@ -238,6 +240,7 @@ coder envs create my-new-powerful-env --cpu 12 --disk 100 --memory 16 --image ub
238
240
cmd .Flags ().IntVarP (& gpus , "gpus" , "g" , 0 , "number GPUs an environment should be provisioned with." )
239
241
cmd .Flags ().StringVarP (& img , "image" , "i" , "" , "name of the image to base the environment off of." )
240
242
cmd .Flags ().BoolVar (& follow , "follow" , false , "follow buildlog after initiating rebuild" )
243
+ cmd .Flags ().BoolVar (& useCVM , "container-vm" , false , "deploy the environment as a Container-based VM" )
241
244
_ = cmd .MarkFlagRequired ("image" )
242
245
return cmd
243
246
}
@@ -252,6 +255,8 @@ func editEnvCmd(user *string) *cobra.Command {
252
255
disk int
253
256
gpus int
254
257
follow bool
258
+ useCVM bool
259
+ notCVM bool
255
260
)
256
261
257
262
cmd := & cobra.Command {
@@ -296,6 +301,8 @@ coder envs edit back-end-env --disk 20`,
296
301
image : img ,
297
302
imageTag : tag ,
298
303
orgName : org ,
304
+ useCVM : useCVM ,
305
+ notCVM : notCVM ,
299
306
})
300
307
if err != nil {
301
308
return err
@@ -328,6 +335,8 @@ coder envs edit back-end-env --disk 20`,
328
335
cmd .Flags ().IntVarP (& disk , "disk" , "d" , 0 , "The amount of disk storage an environment should be provisioned with." )
329
336
cmd .Flags ().IntVarP (& gpus , "gpu" , "g" , 0 , "The amount of disk storage to provision the environment with." )
330
337
cmd .Flags ().BoolVar (& follow , "follow" , false , "follow buildlog after initiating rebuild" )
338
+ cmd .Flags ().BoolVar (& useCVM , "container-vm" , false , "deploy the environment as a Container-based VM" )
339
+ cmd .Flags ().BoolVar (& notCVM , "not-container-vm" , false , "do not deploy the environment as a Container-based VM" )
331
340
return cmd
332
341
}
333
342
@@ -391,8 +400,12 @@ type updateConf struct {
391
400
image string
392
401
imageTag string
393
402
orgName string
403
+ useCVM bool
404
+ notCVM bool
394
405
}
395
406
407
+ func boolP (a bool ) * bool { return & a }
408
+
396
409
func buildUpdateReq (ctx context.Context , client * coder.Client , conf updateConf ) (* coder.UpdateEnvironmentReq , error ) {
397
410
var (
398
411
updateReq coder.UpdateEnvironmentReq
@@ -401,6 +414,16 @@ func buildUpdateReq(ctx context.Context, client *coder.Client, conf updateConf)
401
414
defaultDiskGB int
402
415
)
403
416
417
+ if conf .useCVM && conf .notCVM {
418
+ return nil , xerrors .New ("--container-vm and --not-container-vm flags conflict" )
419
+ }
420
+ if conf .useCVM {
421
+ updateReq .UseContainerVM = boolP (true )
422
+ }
423
+ if conf .notCVM {
424
+ updateReq .UseContainerVM = boolP (false )
425
+ }
426
+
404
427
// If this is not empty it means the user is requesting to change the environment image.
405
428
if conf .image != "" {
406
429
importedImg , err := findImg (ctx , client , findImgConf {
0 commit comments