Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 30, 2024. It is now read-only.
/coder-v1-cliPublic archive

Commit9b94c77

Browse files
authored
Add cvm flag to CLI and fields to coder-sdk (#201)
1 parent58320e4 commit9b94c77

File tree

5 files changed

+62
-31
lines changed

5 files changed

+62
-31
lines changed

‎coder-sdk/client.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@ type Client struct {
1717

1818
// newHTTPClient creates a default underlying http client and sets the auth cookie.
1919
//
20-
// NOTE: As we do not specify a custom transport, the default one from the stdlib will be used,
21-
// resulting in a persistent connection pool.
22-
// We do not set a timeout here as it could cause issue with the websocket.
23-
// The caller is expected to set it when needed.
20+
// NOTE:
21+
// As we do not specify a custom transport, the default one from the stdlib will be used,
22+
// resulting in a persistent connection pool.
23+
// We do not set a timeout here as it could cause issue with the websocket.
24+
// The caller is expected to set it when needed.
2425
//
25-
// WARNING: If the caller sets a custom transport to set TLS settings or a custom CA, the default
26-
// pool will not be used and it might result in a new dns lookup/tls session/socket begin
27-
// established each time.
26+
// WARNING:
27+
// If the caller sets a custom transport to set TLS settings or a custom CA the default
28+
// pool will not be used and it might result in a new dns lookup/tls session/socket begin
29+
// established each time.
2830
func (cClient)newHTTPClient() (*http.Client,error) {
2931
jar,err:=cookiejar.New(nil)
3032
iferr!=nil {

‎coder-sdk/env.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ type Environment struct {
3333
LastConnectionAt time.Time`json:"last_connection_at" table:"-"`
3434
AutoOffThresholdDuration`json:"auto_off_threshold" table:"-"`
3535
SSHAvailablebool`json:"ssh_available" table:"-"`
36+
UseContainerVMbool`json:"use_container_vm" table:"CVM"`
3637
}
3738

3839
// RebuildMessage defines the message shown when an Environment requires a rebuild for it can be accessed.
@@ -71,14 +72,15 @@ const (
7172

7273
// CreateEnvironmentRequest is used to configure a new environment.
7374
typeCreateEnvironmentRequeststruct {
74-
Namestring`json:"name"`
75-
ImageIDstring`json:"image_id"`
76-
ImageTagstring`json:"image_tag"`
77-
CPUCoresfloat32`json:"cpu_cores"`
78-
MemoryGBfloat32`json:"memory_gb"`
79-
DiskGBint`json:"disk_gb"`
80-
GPUsint`json:"gpus"`
81-
Services []string`json:"services"`
75+
Namestring`json:"name"`
76+
ImageIDstring`json:"image_id"`
77+
ImageTagstring`json:"image_tag"`
78+
CPUCoresfloat32`json:"cpu_cores"`
79+
MemoryGBfloat32`json:"memory_gb"`
80+
DiskGBint`json:"disk_gb"`
81+
GPUsint`json:"gpus"`
82+
Services []string`json:"services"`
83+
UseContainerVMbool`json:"use_container_vm"`
8284
}
8385

8486
// CreateEnvironment sends a request to create an environment.
@@ -130,6 +132,7 @@ type UpdateEnvironmentReq struct {
130132
GPUs*int`json:"gpus"`
131133
Services*[]string`json:"services"`
132134
CodeServerReleaseURL*string`json:"code_server_release_url"`
135+
UseContainerVM*bool`json:"use_container_vm"`
133136
}
134137

135138
// RebuildEnvironment requests that the given envID is rebuilt with no changes to its specification.

‎docs/coder_envs_create.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ coder envs create my-new-powerful-env --cpu 12 --disk 100 --memory 16 --image ub
2121
###Options
2222

2323
```
24+
--container-vm deploy the environment as a Container-based VM
2425
-c, --cpu float32 number of cpu cores the environment should be provisioned with.
2526
-d, --disk int GB of disk storage an environment should be provisioned with.
2627
--follow follow buildlog after initiating rebuild

‎docs/coder_envs_edit.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,17 @@ coder envs edit back-end-env --disk 20
2121
###Options
2222

2323
```
24-
-c, --cpu float32 The number of cpu cores the environment should be provisioned with.
25-
-d, --disk int The amount of disk storage an environment should be provisioned with.
26-
--follow follow buildlog after initiating rebuild
27-
-g, --gpu int The amount of disk storage to provision the environment with.
28-
-h, --help help for edit
29-
-i, --image string name of the image you want the environment to be based off of.
30-
-m, --memory float32 The amount of RAM an environment should be provisioned with.
31-
-o, --org string name of the organization the environment should be created under.
32-
-t, --tag string image tag of the image you want to base the environment off of. (default "latest")
24+
--container-vm deploy the environment as a Container-based VM
25+
-c, --cpu float32 The number of cpu cores the environment should be provisioned with.
26+
-d, --disk int The amount of disk storage an environment should be provisioned with.
27+
--follow follow buildlog after initiating rebuild
28+
-g, --gpu int The amount of disk storage to provision the environment with.
29+
-h, --help help for edit
30+
-i, --image string name of the image you want the environment to be based off of.
31+
-m, --memory float32 The amount of RAM an environment should be provisioned with.
32+
--not-container-vm do not deploy the environment as a Container-based VM
33+
-o, --org string name of the organization the environment should be created under.
34+
-t, --tag string image tag of the image you want to base the environment off of. (default "latest")
3335
```
3436

3537
###Options inherited from parent commands

‎internal/cmd/envs.go

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ func createEnvCmd(user *string) *cobra.Command {
148148
imgstring
149149
tagstring
150150
followbool
151+
useCVMbool
151152
)
152153

153154
cmd:=&cobra.Command{
@@ -189,13 +190,14 @@ coder envs create my-new-powerful-env --cpu 12 --disk 100 --memory 16 --image ub
189190

190191
// ExactArgs(1) ensures our name value can't panic on an out of bounds.
191192
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,
199201
}
200202

201203
// 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
238240
cmd.Flags().IntVarP(&gpus,"gpus","g",0,"number GPUs an environment should be provisioned with.")
239241
cmd.Flags().StringVarP(&img,"image","i","","name of the image to base the environment off of.")
240242
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")
241244
_=cmd.MarkFlagRequired("image")
242245
returncmd
243246
}
@@ -252,6 +255,8 @@ func editEnvCmd(user *string) *cobra.Command {
252255
diskint
253256
gpusint
254257
followbool
258+
useCVMbool
259+
notCVMbool
255260
)
256261

257262
cmd:=&cobra.Command{
@@ -296,6 +301,8 @@ coder envs edit back-end-env --disk 20`,
296301
image:img,
297302
imageTag:tag,
298303
orgName:org,
304+
useCVM:useCVM,
305+
notCVM:notCVM,
299306
})
300307
iferr!=nil {
301308
returnerr
@@ -328,6 +335,8 @@ coder envs edit back-end-env --disk 20`,
328335
cmd.Flags().IntVarP(&disk,"disk","d",0,"The amount of disk storage an environment should be provisioned with.")
329336
cmd.Flags().IntVarP(&gpus,"gpu","g",0,"The amount of disk storage to provision the environment with.")
330337
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")
331340
returncmd
332341
}
333342

@@ -391,8 +400,12 @@ type updateConf struct {
391400
imagestring
392401
imageTagstring
393402
orgNamestring
403+
useCVMbool
404+
notCVMbool
394405
}
395406

407+
funcboolP(abool)*bool {return&a }
408+
396409
funcbuildUpdateReq(ctx context.Context,client*coder.Client,confupdateConf) (*coder.UpdateEnvironmentReq,error) {
397410
var (
398411
updateReq coder.UpdateEnvironmentReq
@@ -401,6 +414,16 @@ func buildUpdateReq(ctx context.Context, client *coder.Client, conf updateConf)
401414
defaultDiskGBint
402415
)
403416

417+
ifconf.useCVM&&conf.notCVM {
418+
returnnil,xerrors.New("--container-vm and --not-container-vm flags conflict")
419+
}
420+
ifconf.useCVM {
421+
updateReq.UseContainerVM=boolP(true)
422+
}
423+
ifconf.notCVM {
424+
updateReq.UseContainerVM=boolP(false)
425+
}
426+
404427
// If this is not empty it means the user is requesting to change the environment image.
405428
ifconf.image!="" {
406429
importedImg,err:=findImg(ctx,client,findImgConf{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp