8000 feat: run a terraform plan before creating workspaces with the given template parameters by deansheather · Pull Request #1732 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

feat: run a terraform plan before creating workspaces with the given template parameters #1732

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jun 1, 2022
Prev Previous commit
Next Next commit
fix
  • Loading branch information
deansheather committed May 27, 2022
commit 4078fd112e0286fab9d1ea0e83768c9d3d9a10d7
1 change: 1 addition & 0 deletions cli/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ func create() *cobra.Command {
// Run a plan with the given parameters to check correctness
after := time.Now()
planJob, err := client.CreateTemplateVersionPlan(cmd.Context(), templateVersion.ID, codersdk.CreateTemplateVersionPlanRequest{
WorkspaceName: workspaceName,
ParameterValues: parameters,
})
if err != nil {
Expand Down
4 changes: 3 additions & 1 deletion coderd/provisionerdaemons.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ type workspaceProvisionJob struct {
// The input for a "template_version_plan" job.
type templateVersionPlanJob struct {
TemplateVersionID uuid.UUID `json:"template_version_id"`
WorkspaceName string `json:"workspace_name"`
ParameterValues []database.ParameterValue `json:"parameter_values"`
}

Expand Down Expand Up @@ -287,7 +288,8 @@ func (server *provisionerdServer) AcquireJob(ctx context.Context, _ *proto.Empty
TemplatePlan: &proto.AcquiredJob_TemplatePlan{
ParameterValues: protoParameters,
Metadata: &sdkproto.Provision_Metadata{
CoderUrl: server.AccessURL.String(),
CoderUrl: server.AccessURL.String(),
WorkspaceName: input.WorkspaceName,
},
},
}
Expand Down
1 change: 1 addition & 0 deletions coderd/templateversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ func (api *API) createTemplateVersionPlan(rw http.ResponseWriter, r *http.Reques
// Marshal template version plan job with the parameters from the request.
input, err := json.Marshal(templateVersionPlanJob{
TemplateVersionID: templateVersion.ID,
WorkspaceName: req.WorkspaceName,
ParameterValues: parameterValues,
})
if err != nil {
Expand Down
13 changes: 4 additions & 9 deletions coderd/templateversions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,16 +505,11 @@ func TestTemplateVersionPlan(t *testing.T) {
defer close(logsDone)

logCount := 0
for {
select {
case _, ok := <-logs:
if !ok {
assert.GreaterOrEqual(t, logCount, 1, "unexpected log count")
return
}
logCount++
}
for range logs {
logCount++
}
assert.GreaterOrEqual(t, logCount, 1, "unexpected log count")
return
}()

// Wait for the job to complete
Expand Down
1 change: 1 addition & 0 deletions codersdk/templateversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ func (c *Client) TemplateVersionLogsAfter(ctx context.Context, version uuid.UUID
// CreateTemplateVersionPlanRequest defines the request parameters for
// CreateTemplateVersionPlan.
type CreateTemplateVersionPlanRequest struct {
WorkspaceName string
ParameterValues []CreateParameterRequest
}

Expand Down
0