Skip to content

feat: Add dry run for provisioners #178

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 8 commits into from
Feb 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add resource detection on project import
  • Loading branch information
kylecarbs committed Feb 7, 2022
commit d15f0b3c4545c948514769ffdb08629f3edab2fc
1 change: 1 addition & 0 deletions coderd/projectversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ func TestProjectVersionParametersByOrganizationAndName(t *testing.T) {
},
},
}},
Provision: echo.ProvisionComplete,
})
coderdtest.AwaitProjectVersionImported(t, client, user.Organization, project.Name, version.Name)
params, err := client.ProjectVersionParameters(context.Background(), user.Organization, project.Name, version.Name)
Expand Down
4 changes: 2 additions & 2 deletions provisioner/terraform/provision.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ func (t *terraform) Provision(request *proto.Provision_Request, stream proto.DRP

if request.DryRun {
return t.runTerraformPlan(ctx, terraform, request, stream)
} else {
return t.runTerraformApply(ctx, terraform, request, stream, statefilePath)
}
return t.runTerraformApply(ctx, terraform, request, stream, statefilePath)
}

func (t *terraform) runTerraformPlan(ctx context.Context, terraform *tfexec.Terraform, request *proto.Provision_Request, stream proto.DRPCProvisioner_ProvisionStream) error {
Expand Down Expand Up @@ -150,6 +149,7 @@ func (t *terraform) runTerraformPlan(ctx context.Context, terraform *tfexec.Terr
if err != nil {
return xerrors.Errorf("apply terraform: %w", err)
}
_ = reader.Close()
t.logger.Debug(ctx, "ran plan")
<-closeChan

Expand Down
1 change: 1 addition & 0 deletions provisioner/terraform/provision_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ func TestProvision(t *testing.T) {
for {
msg, err := response.Recv()
if msg != nil && msg.GetLog() != nil {
t.Logf("log: [%s] %s", msg.GetLog().Level, msg.GetLog().Output)
continue
}
if testCase.Error {
Expand Down
150 changes: 81 additions & 69 deletions provisionerd/proto/provisionerd.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion provisionerd/proto/provisionerd.proto
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ message CompletedJob {
}
message ProjectImport {
repeated provisioner.ParameterSchema parameter_schemas = 1;
repeated TransitionedResource resources = 2;
repeated provisioner.Resource start_resources = 2;
repeated provisioner.Resource stop_resources = 3;
}
string job_id = 1;
oneof type {
Expand Down
Loading