Skip to content

Commit 90b5e35

Browse files
committed
Fix: dry run
1 parent 74315b2 commit 90b5e35

File tree

13 files changed

+262
-196
lines changed

13 files changed

+262
-196
lines changed

cli/create.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,9 @@ PromptRichParamLoop:
296296

297297
// Run a dry-run with the given parameters to check correctness
298298
dryRun, err := client.CreateTemplateVersionDryRun(cmd.Context(), templateVersion.ID, codersdk.CreateTemplateVersionDryRunRequest{
299-
WorkspaceName: args.NewWorkspaceName,
300-
ParameterValues: legacyParameters,
301-
// TODO RichParameterValues
299+
WorkspaceName: args.NewWorkspaceName,
300+
ParameterValues: legacyParameters,
301+
RichParameterValues: richParameters,
302302
})
303303
if err != nil {
304304
return nil, xerrors.Errorf("begin workspace dry-run: %w", err)

coderd/apidoc/docs.go

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/provisionerdserver/provisionerdserver.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ func (server *Server) AcquireJob(ctx context.Context, _ *proto.Empty) (*proto.Ac
235235

236236
protoJob.Type = &proto.AcquiredJob_TemplateDryRun_{
237237
TemplateDryRun: &proto.AcquiredJob_TemplateDryRun{
238-
ParameterValues: protoParameters,
238+
ParameterValues: protoParameters,
239+
RichParameterValues: convertRichParameterValues(input.RichParameterValues),
239240
Metadata: &sdkproto.Provision_Metadata{
240241
CoderUrl: server.AccessURL.String(),
241242
WorkspaceName: input.WorkspaceName,
@@ -1175,9 +1176,10 @@ type WorkspaceProvisionJob struct {
11751176

11761177
// TemplateVersionDryRunJob is the payload for the "template_version_dry_run" job type.
11771178
type TemplateVersionDryRunJob struct {
1178-
TemplateVersionID uuid.UUID `json:"template_version_id"`
1179-
WorkspaceName string `json:"workspace_name"`
1180-
ParameterValues []database.ParameterValue `json:"parameter_values"`
1179+
TemplateVersionID uuid.UUID `json:"template_version_id"`
1180+
WorkspaceName string `json:"workspace_name"`
1181+
ParameterValues []database.ParameterValue `json:"parameter_values"`
1182+
RichParameterValues []database.WorkspaceBuildParameter `json:"rich_parameter_values"`
11811183
}
11821184

11831185
// ProvisionerJobLogsNotifyMessage is the payload published on

coderd/templateversions.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,12 +362,22 @@ func (api *API) postTemplateVersionDryRun(rw http.ResponseWriter, r *http.Reques
362362
}
363363
}
364364

365+
richParameterValues := make([]database.WorkspaceBuildParameter, len(req.RichParameterValues))
366+
for i, v := range req.RichParameterValues {
367+
richParameterValues[i] = database.WorkspaceBuildParameter{
368+
WorkspaceBuildID: uuid.Nil,
369+
Name: v.Name,
370+
Value: v.Value,
371+
}
372+
}
373+
365374
// Marshal template version dry-run job with the parameters from the
366375
// request.
367376
input, err := json.Marshal(provisionerdserver.TemplateVersionDryRunJob{
368-
TemplateVersionID: templateVersion.ID,
369-
WorkspaceName: req.WorkspaceName,
370-
ParameterValues: parameterValues,
377+
TemplateVersionID: templateVersion.ID,
378+
WorkspaceName: req.WorkspaceName,
379+
ParameterValues: parameterValues,
380+
RichParameterValues: richParameterValues,
371381
})
372382
if err != nil {
373383
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{

codersdk/templateversions.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,9 @@ func (c *Client) TemplateVersionLogsAfter(ctx context.Context, version uuid.UUID
143143
// CreateTemplateVersionDryRunRequest defines the request parameters for
144144
// CreateTemplateVersionDryRun.
145145
type CreateTemplateVersionDryRunRequest struct {
146-
WorkspaceName string `json:"workspace_name"`
147-
ParameterValues []CreateParameterRequest `json:"parameter_values"`
146+
WorkspaceName string `json:"workspace_name"`
147+
ParameterValues []CreateParameterRequest `json:"parameter_values"`
148+
RichParameterValues []WorkspaceBuildParameter `json:"rich_parameter_values"`
148149
}
149150

150151
// CreateTemplateVersionDryRun begins a dry-run provisioner job against the

docs/api/schemas.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -762,16 +762,23 @@ CreateParameterRequest is a structure used to create a new parameter value for a
762762
"source_value": "string"
763763
}
764764
],
765+
"rich_parameter_values": [
766+
{
767+
"name": "string",
768+
"value": "string"
769+
}
770+
],
765771
"workspace_name": "string"
766772
}
767773
```
768774

769775
### Properties
770776

771-
| Name | Type | Required | Restrictions | Description |
772-
| ------------------ | --------------------------------------------------------------------------- | -------- | ------------ | ---------------------------------------------------------------------------------- |
773-
| `parameter_values` | array of [codersdk.CreateParameterRequest](#codersdkcreateparameterrequest) | false | | Parameter values is a structure used to create a new parameter value for a scope.] |
774-
| `workspace_name` | string | false | | |
777+
| Name | Type | Required | Restrictions | Description |
778+
| ----------------------- | ----------------------------------------------------------------------------- | -------- | ------------ | ---------------------------------------------------------------------------------- |
779+
| `parameter_values` | array of [codersdk.CreateParameterRequest](#codersdkcreateparameterrequest) | false | | Parameter values is a structure used to create a new parameter value for a scope.] |
780+
| `rich_parameter_values` | array of [codersdk.WorkspaceBuildParameter](#codersdkworkspacebuildparameter) | false | | |
781+
| `workspace_name` | string | false | | |
775782

776783
## codersdk.CreateTestAuditLogRequest
777784

docs/api/templates.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,12 @@ curl -X POST http://coder-server:8080/api/v2/organizations/{organization}/templa
408408
"source_value": "string"
409409
}
410410
],
411+
"rich_parameter_values": [
412+
{
413+
"name": "string",
414+
"value": "string"
415+
}
416+
],
411417
"workspace_name": "string"
412418
}
413419
```
@@ -1293,6 +1299,12 @@ curl -X POST http://coder-server:8080/api/v2/templateversions/{templateversion}/
12931299
"source_value": "string"
12941300
}
12951301
],
1302+
"rich_parameter_values": [
1303+
{
1304+
"name": "string",
1305+
"value": "string"
1306+
}
1307+
],
12961308
"workspace_name": "string"
12971309
}
12981310
```

0 commit comments

Comments
 (0)