From 24c3f70ad7f0694fc68709f6e28424a562eef4d0 Mon Sep 17 00:00:00 2001 From: Charlie Moog Date: Sat, 5 Dec 2020 21:07:43 +0000 Subject: [PATCH 1/4] Add cvm flag to CLI and fields to coder-sdk --- coder-sdk/env.go | 19 +++++++++++-------- internal/cmd/envs.go | 35 ++++++++++++++++++++++++++++------- 2 files changed, 39 insertions(+), 15 deletions(-) diff --git a/coder-sdk/env.go b/coder-sdk/env.go index 62cf0812..e8962971 100644 --- a/coder-sdk/env.go +++ b/coder-sdk/env.go @@ -33,6 +33,7 @@ type Environment struct { LastConnectionAt time.Time `json:"last_connection_at" table:"-"` AutoOffThreshold Duration `json:"auto_off_threshold" table:"-"` SSHAvailable bool `json:"ssh_available" table:"-"` + UseContainerVM bool `json:"use_container_vm" table:"CVM"` } // RebuildMessage defines the message shown when an Environment requires a rebuild for it can be accessed. @@ -71,14 +72,15 @@ const ( // CreateEnvironmentRequest is used to configure a new environment. type CreateEnvironmentRequest struct { - Name string `json:"name"` - ImageID string `json:"image_id"` - ImageTag string `json:"image_tag"` - CPUCores float32 `json:"cpu_cores"` - MemoryGB float32 `json:"memory_gb"` - DiskGB int `json:"disk_gb"` - GPUs int `json:"gpus"` - Services []string `json:"services"` + Name string `json:"name"` + ImageID string `json:"image_id"` + ImageTag string `json:"image_tag"` + CPUCores float32 `json:"cpu_cores"` + MemoryGB float32 `json:"memory_gb"` + DiskGB int `json:"disk_gb"` + GPUs int `json:"gpus"` + Services []string `json:"services"` + UseContainerVM bool `json:"use_container_vm"` } // CreateEnvironment sends a request to create an environment. @@ -130,6 +132,7 @@ type UpdateEnvironmentReq struct { GPUs *int `json:"gpus"` Services *[]string `json:"services"` CodeServerReleaseURL *string `json:"code_server_release_url"` + UseContainerVM *bool `json:"use_container_vm"` } // RebuildEnvironment requests that the given envID is rebuilt with no changes to its specification. diff --git a/internal/cmd/envs.go b/internal/cmd/envs.go index e12e9d35..85555e4c 100644 --- a/internal/cmd/envs.go +++ b/internal/cmd/envs.go @@ -148,6 +148,7 @@ func createEnvCmd(user *string) *cobra.Command { img string tag string follow bool + useCVM bool ) cmd := &cobra.Command{ @@ -189,13 +190,14 @@ coder envs create my-new-powerful-env --cpu 12 --disk 100 --memory 16 --image ub // ExactArgs(1) ensures our name value can't panic on an out of bounds. createReq := &coder.CreateEnvironmentRequest{ - Name: args[0], - ImageID: importedImg.ID, - ImageTag: tag, - CPUCores: cpu, - MemoryGB: memory, - DiskGB: disk, - GPUs: gpus, + Name: args[0], + ImageID: importedImg.ID, + ImageTag: tag, + CPUCores: cpu, + MemoryGB: memory, + DiskGB: disk, + GPUs: gpus, + UseContainerVM: useCVM, } // 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 cmd.Flags().IntVarP(&gpus, "gpus", "g", 0, "number GPUs an environment should be provisioned with.") cmd.Flags().StringVarP(&img, "image", "i", "", "name of the image to base the environment off of.") cmd.Flags().BoolVar(&follow, "follow", false, "follow buildlog after initiating rebuild") + cmd.Flags().BoolVar(&useCVM, "container-vm", false, "deploy the environment as a Container-based VM") _ = cmd.MarkFlagRequired("image") return cmd } @@ -252,6 +255,8 @@ func editEnvCmd(user *string) *cobra.Command { disk int gpus int follow bool + useCVM bool + notCVM bool ) cmd := &cobra.Command{ @@ -328,6 +333,8 @@ coder envs edit back-end-env --disk 20`, cmd.Flags().IntVarP(&disk, "disk", "d", 0, "The amount of disk storage an environment should be provisioned with.") cmd.Flags().IntVarP(&gpus, "gpu", "g", 0, "The amount of disk storage to provision the environment with.") cmd.Flags().BoolVar(&follow, "follow", false, "follow buildlog after initiating rebuild") + cmd.Flags().BoolVar(&useCVM, "container-vm", false, "deploy the environment as a Container-based VM") + cmd.Flags().BoolVar(¬CVM, "not-container-vm", false, "do not deploy the environment as a Container-based VM") return cmd } @@ -391,8 +398,12 @@ type updateConf struct { image string imageTag string orgName string + useCVM bool + noCVM bool } +func boolP(a bool) *bool { return &a } + func buildUpdateReq(ctx context.Context, client *coder.Client, conf updateConf) (*coder.UpdateEnvironmentReq, error) { var ( updateReq coder.UpdateEnvironmentReq @@ -401,6 +412,16 @@ func buildUpdateReq(ctx context.Context, client *coder.Client, conf updateConf) defaultDiskGB int ) + if conf.useCVM && conf.noCVM { + return nil, xerrors.New("--container-vm and --not-container-vm flags conflict") + } + if conf.useCVM { + updateReq.UseContainerVM = boolP(true) + } + if conf.noCVM { + updateReq.UseContainerVM = boolP(false) + } + // If this is not empty it means the user is requesting to change the environment image. if conf.image != "" { importedImg, err := findImg(ctx, client, findImgConf{ From a455cb80017ff4378787078e151049fad816ceb4 Mon Sep 17 00:00:00 2001 From: Charlie Moog Date: Sat, 5 Dec 2020 21:18:53 +0000 Subject: [PATCH 2/4] fixup! Add cvm flag to CLI and fields to coder-sdk --- coder-sdk/client.go | 16 +++++++++------- internal/cmd/envs.go | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/coder-sdk/client.go b/coder-sdk/client.go index 8f512e05..3f859bde 100644 --- a/coder-sdk/client.go +++ b/coder-sdk/client.go @@ -17,14 +17,16 @@ type Client struct { // newHTTPClient creates a default underlying http client and sets the auth cookie. // -// NOTE: As we do not specify a custom transport, the default one from the stdlib will be used, -// resulting in a persistent connection pool. -// We do not set a timeout here as it could cause issue with the websocket. -// The caller is expected to set it when needed. +// NOTE: +// As we do not specify a custom transport, the default one from the stdlib will be used, +// resulting in a persistent connection pool. +// We do not set a timeout here as it could cause issue with the websocket. +// The caller is expected to set it when needed. // -// WARNING: If the caller sets a custom transport to set TLS settings or a custom CA, the default -// pool will not be used and it might result in a new dns lookup/tls session/socket begin -// established each time. +// WARNING: +// If the caller sets a custom transport to set TLS settings or a custom CA the default +// pool will not be used and it might result in a new dns lookup/tls session/socket begin +// established each time. func (c Client) newHTTPClient() (*http.Client, error) { jar, err := cookiejar.New(nil) if err != nil { diff --git a/internal/cmd/envs.go b/internal/cmd/envs.go index 85555e4c..2690eb51 100644 --- a/internal/cmd/envs.go +++ b/internal/cmd/envs.go @@ -256,7 +256,7 @@ func editEnvCmd(user *string) *cobra.Command { gpus int follow bool useCVM bool - notCVM bool + notCVM bool ) cmd := &cobra.Command{ From 83d165cec8aac57cd961a2e621337c5d40777366 Mon Sep 17 00:00:00 2001 From: Charlie Moog Date: Sat, 5 Dec 2020 21:19:21 +0000 Subject: [PATCH 3/4] fixup! Add cvm flag to CLI and fields to coder-sdk --- docs/coder_envs_create.md | 1 + docs/coder_envs_edit.md | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/docs/coder_envs_create.md b/docs/coder_envs_create.md index 96b6048b..91daaf07 100644 --- a/docs/coder_envs_create.md +++ b/docs/coder_envs_create.md @@ -21,6 +21,7 @@ coder envs create my-new-powerful-env --cpu 12 --disk 100 --memory 16 --image ub ### Options ``` + --container-vm deploy the environment as a Container-based VM -c, --cpu float32 number of cpu cores the environment should be provisioned with. -d, --disk int GB of disk storage an environment should be provisioned with. --follow follow buildlog after initiating rebuild diff --git a/docs/coder_envs_edit.md b/docs/coder_envs_edit.md index 72416b2c..da94adcc 100644 --- a/docs/coder_envs_edit.md +++ b/docs/coder_envs_edit.md @@ -21,15 +21,17 @@ coder envs edit back-end-env --disk 20 ### Options ``` - -c, --cpu float32 The number of cpu cores the environment should be provisioned with. - -d, --disk int The amount of disk storage an environment should be provisioned with. - --follow follow buildlog after initiating rebuild - -g, --gpu int The amount of disk storage to provision the environment with. - -h, --help help for edit - -i, --image string name of the image you want the environment to be based off of. - -m, --memory float32 The amount of RAM an environment should be provisioned with. - -o, --org string name of the organization the environment should be created under. - -t, --tag string image tag of the image you want to base the environment off of. (default "latest") + --container-vm deploy the environment as a Container-based VM + -c, --cpu float32 The number of cpu cores the environment should be provisioned with. + -d, --disk int The amount of disk storage an environment should be provisioned with. + --follow follow buildlog after initiating rebuild + -g, --gpu int The amount of disk storage to provision the environment with. + -h, --help help for edit + -i, --image string name of the image you want the environment to be based off of. + -m, --memory float32 The amount of RAM an environment should be provisioned with. + --not-container-vm do not deploy the environment as a Container-based VM + -o, --org string name of the organization the environment should be created under. + -t, --tag string image tag of the image you want to base the environment off of. (default "latest") ``` ### Options inherited from parent commands From 5041db93935ccb53143fada8c36afd76def0b141 Mon Sep 17 00:00:00 2001 From: Charlie Moog Date: Tue, 8 Dec 2020 04:02:21 +0000 Subject: [PATCH 4/4] fixup! Add cvm flag to CLI and fields to coder-sdk --- internal/cmd/envs.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/cmd/envs.go b/internal/cmd/envs.go index 2690eb51..8ba33fb8 100644 --- a/internal/cmd/envs.go +++ b/internal/cmd/envs.go @@ -301,6 +301,8 @@ coder envs edit back-end-env --disk 20`, image: img, imageTag: tag, orgName: org, + useCVM: useCVM, + notCVM: notCVM, }) if err != nil { return err @@ -399,7 +401,7 @@ type updateConf struct { imageTag string orgName string useCVM bool - noCVM bool + notCVM bool } func boolP(a bool) *bool { return &a } @@ -412,13 +414,13 @@ func buildUpdateReq(ctx context.Context, client *coder.Client, conf updateConf) defaultDiskGB int ) - if conf.useCVM && conf.noCVM { + if conf.useCVM && conf.notCVM { return nil, xerrors.New("--container-vm and --not-container-vm flags conflict") } if conf.useCVM { updateReq.UseContainerVM = boolP(true) } - if conf.noCVM { + if conf.notCVM { updateReq.UseContainerVM = boolP(false) } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy