diff --git a/coder-sdk/env.go b/coder-sdk/env.go index 7b3182be..7743213c 100644 --- a/coder-sdk/env.go +++ b/coder-sdk/env.go @@ -2,6 +2,7 @@ package coder import ( "context" + "encoding/json" "io" "net/http" "net/url" @@ -84,6 +85,10 @@ type CreateEnvironmentRequest struct { GPUs int `json:"gpus"` Services []string `json:"services"` UseContainerVM bool `json:"use_container_vm"` + + // Template comes from the parse template route on cemanager. + // This field should never be manually populated + Template Template `json:"template,omitempty"` } // CreateEnvironment sends a request to create an environment. @@ -104,24 +109,9 @@ type ParseTemplateRequest struct { } // Template is a Workspaces As Code (WAC) template. -type Template struct { - Workspace Workspace `json:"workspace"` -} - -// Workspace defines values on the workspace that can be configured. -type Workspace struct { - Name string `json:"name"` - Image string `json:"image"` - ContainerBasedVM bool `json:"container-based-vm"` - Resources Resources `json:"resources"` -} - -// Resources defines compute values that can be configured for a workspace. -type Resources struct { - CPU float32 `json:"cpu" ` - Memory float32 `json:"memory"` - Disk int `json:"disk"` -} +// For now, let's not interpret it on the CLI level. We just need +// to forward this as part of the create env request. +type Template = json.RawMessage // ParseTemplate parses a template config. It support both remote repositories and local files. // If a local file is specified then all other values in the request are ignored. diff --git a/internal/cmd/envs.go b/internal/cmd/envs.go index d5f556cd..be131b9f 100644 --- a/internal/cmd/envs.go +++ b/internal/cmd/envs.go @@ -317,24 +317,8 @@ coder envs create-from-repo -f coder.yaml`, return xerrors.Errorf("parse environment template config: %w", err) } - importedImg, err := findImg(ctx, client, findImgConf{ - email: coder.Me, - imgName: tpl.Workspace.Image, - orgName: org, - }) - if err != nil { - return err - } - env, err := client.CreateEnvironment(ctx, coder.CreateEnvironmentRequest{ - Name: tpl.Workspace.Name, - ImageID: importedImg.ID, - OrgID: importedImg.OrganizationID, - ImageTag: importedImg.DefaultTag.Tag, - CPUCores: tpl.Workspace.Resources.CPU, - MemoryGB: tpl.Workspace.Resources.Memory, - DiskGB: tpl.Workspace.Resources.Disk, - UseContainerVM: tpl.Workspace.ContainerBasedVM, + Template: tpl, }) if err != nil { return xerrors.Errorf("create environment: %w", err)