Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit a1d8a19

Browse files
committed
Add orgid to template parsing
1 parent 79b7089 commit a1d8a19

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

coder-sdk/env.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,19 @@ type Template = json.RawMessage
117117

118118
// ParseTemplate parses a template config. It support both remote repositories and local files.
119119
// If a local file is specified then all other values in the request are ignored.
120-
func (c *DefaultClient) ParseTemplate(ctx context.Context, req ParseTemplateRequest) (Template, error) {
120+
// TODO: @emryk unsure if `orgID` should really be passed as a param this way
121+
func (c *DefaultClient) ParseTemplate(ctx context.Context, req ParseTemplateRequest, orgID string) (Template, error) {
121122
const path = "/api/private/environments/template/parse"
122123
var (
123124
tpl Template
124125
opts []requestOption
125126
headers = http.Header{}
126127
)
127128

129+
opts = append(opts, withQueryParams(url.Values{"org-id": []string{orgID}}))
130+
128131
if req.Local == nil {
129-
if err := c.requestBody(ctx, http.MethodPost, path, req, &tpl); err != nil {
132+
if err := c.requestBody(ctx, http.MethodPost, path, req, &tpl, opts...); err != nil {
130133
return tpl, err
131134
}
132135
return tpl, nil

coder-sdk/interface.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ type Client interface {
7979

8080
// ParseTemplate parses a template config. It support both remote repositories and local files.
8181
// If a local file is specified then all other values in the request are ignored.
82-
ParseTemplate(ctx context.Context, req ParseTemplateRequest) (Template, error)
82+
ParseTemplate(ctx context.Context, req ParseTemplateRequest, orgID string) (Template, error)
8383

8484
// CreateEnvironmentFromRepo sends a request to create an environment from a repository.
8585
CreateEnvironmentFromRepo(ctx context.Context, orgID string, req Template) (*Environment, error)

internal/cmd/envs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ coder envs create-from-config -f coder.yaml`,
359359
Local: rd,
360360
}
361361

362-
tpl, err := client.ParseTemplate(ctx, req)
362+
tpl, err := client.ParseTemplate(ctx, req, userOrg.ID)
363363
if err != nil {
364364
return handleAPIError(err)
365365
}

0 commit comments

Comments
 (0)