Skip to content
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

Adding support to configure execution mode #92

Merged
merged 4 commits into from
Sep 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module github.com/terraform-providers/terraform-provider-tfe

require (
github.com/hashicorp/go-hclog v0.0.0-20190109152822-4783caec6f2e // indirect
github.com/hashicorp/go-tfe v0.3.19
github.com/hashicorp/go-tfe v0.3.24
github.com/hashicorp/go-version v1.1.0
github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce
github.com/hashicorp/terraform v0.12.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ github.com/hashicorp/go-slug v0.3.0/go.mod h1:I5tq5Lv0E2xcNXNkmx7BSfzi1PsJ2cNjs3
github.com/hashicorp/go-sockaddr v0.0.0-20180320115054-6d291a969b86/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU=
github.com/hashicorp/go-tfe v0.3.16 h1:GS2yv580p0co4j3FBVaC6Zahd9mxdCGehhJ0qqzFMH0=
github.com/hashicorp/go-tfe v0.3.16/go.mod h1:SuPHR+OcxvzBZNye7nGPfwZTEyd3rWPfLVbCgyZPezM=
github.com/hashicorp/go-tfe v0.3.19 h1:fjaKXHVGeZA76TRMux/n24pywnTZGaIvuh56XYWxvbE=
github.com/hashicorp/go-tfe v0.3.19/go.mod h1:SuPHR+OcxvzBZNye7nGPfwZTEyd3rWPfLVbCgyZPezM=
github.com/hashicorp/go-tfe v0.3.24 h1:pqUiGQf3pZnDa7ZRtRtdHWMxt8Uhu1oWJA3m3JuJfIA=
github.com/hashicorp/go-tfe v0.3.24/go.mod h1:SuPHR+OcxvzBZNye7nGPfwZTEyd3rWPfLVbCgyZPezM=
github.com/hashicorp/go-uuid v1.0.0 h1:RS8zrF7PhGwyNPOtxSClXXj9HA8feRnJzgnI1RJCSnM=
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE=
Expand Down
6 changes: 6 additions & 0 deletions tfe/data_source_workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ func dataSourceTFEWorkspace() *schema.Resource {
Computed: true,
},

"operations": {
Type: schema.TypeBool,
Computed: true,
},

"queue_all_runs": {
Type: schema.TypeBool,
Computed: true,
Expand Down Expand Up @@ -109,6 +114,7 @@ func dataSourceTFEWorkspaceRead(d *schema.ResourceData, meta interface{}) error
// Update the config.
d.Set("auto_apply", workspace.AutoApply)
d.Set("file_triggers_enabled", workspace.FileTriggersEnabled)
d.Set("operations", workspace.Operations)
d.Set("queue_all_runs", workspace.QueueAllRuns)
d.Set("terraform_version", workspace.TerraformVersion)
d.Set("trigger_prefixes", workspace.TriggerPrefixes)
Expand Down
18 changes: 14 additions & 4 deletions tfe/resource_tfe_workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ func resourceTFEWorkspace() *schema.Resource {
Default: true,
},

"ssh_key_id": {
Type: schema.TypeString,
"operations": {
Type: schema.TypeBool,
Optional: true,
Default: "",
Default: true,
},

"queue_all_runs": {
Expand All @@ -55,6 +55,12 @@ func resourceTFEWorkspace() *schema.Resource {
Default: true,
},

"ssh_key_id": {
Type: schema.TypeString,
Optional: true,
Default: "",
},

"terraform_version": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -124,6 +130,7 @@ func resourceTFEWorkspaceCreate(d *schema.ResourceData, meta interface{}) error
Name: tfe.String(name),
AutoApply: tfe.Bool(d.Get("auto_apply").(bool)),
FileTriggersEnabled: tfe.Bool(d.Get("file_triggers_enabled").(bool)),
Operations: tfe.Bool(d.Get("operations").(bool)),
QueueAllRuns: tfe.Bool(d.Get("queue_all_runs").(bool)),
}

Expand Down Expand Up @@ -243,6 +250,7 @@ func resourceTFEWorkspaceRead(d *schema.ResourceData, meta interface{}) error {
d.Set("name", workspace.Name)
d.Set("auto_apply", workspace.AutoApply)
d.Set("file_triggers_enabled", workspace.FileTriggersEnabled)
d.Set("operations", workspace.Operations)
d.Set("queue_all_runs", workspace.QueueAllRuns)
d.Set("terraform_version", workspace.TerraformVersion)
d.Set("trigger_prefixes", workspace.TriggerPrefixes)
Expand Down Expand Up @@ -304,12 +312,14 @@ func resourceTFEWorkspaceUpdate(d *schema.ResourceData, meta interface{}) error

if d.HasChange("name") || d.HasChange("auto_apply") || d.HasChange("queue_all_runs") ||
d.HasChange("terraform_version") || d.HasChange("working_directory") || d.HasChange("vcs_repo") ||
d.HasChange("file_triggers_enabled") || d.HasChange("trigger_prefixes") {
d.HasChange("file_triggers_enabled") || d.HasChange("trigger_prefixes") ||
d.HasChange("operations") {
// Create a new options struct.
options := tfe.WorkspaceUpdateOptions{
Name: tfe.String(d.Get("name").(string)),
AutoApply: tfe.Bool(d.Get("auto_apply").(bool)),
FileTriggersEnabled: tfe.Bool(d.Get("file_triggers_enabled").(bool)),
Operations: tfe.Bool(d.Get("operations").(bool)),
QueueAllRuns: tfe.Bool(d.Get("queue_all_runs").(bool)),
}

Expand Down
20 changes: 20 additions & 0 deletions tfe/resource_tfe_workspace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ func TestAccTFEWorkspace_basic(t *testing.T) {
"tfe_workspace.foobar", "auto_apply", "true"),
resource.TestCheckResourceAttr(
"tfe_workspace.foobar", "file_triggers_enabled", "true"),
resource.TestCheckResourceAttr(
"tfe_workspace.foobar", "operations", "true"),
resource.TestCheckResourceAttr(
"tfe_workspace.foobar", "queue_all_runs", "true"),
resource.TestCheckResourceAttr(
Expand Down Expand Up @@ -141,6 +143,8 @@ func TestAccTFEWorkspace_monorepo(t *testing.T) {
"tfe_workspace.foobar", "name", "workspace-monorepo"),
resource.TestCheckResourceAttr(
"tfe_workspace.foobar", "file_triggers_enabled", "true"),
resource.TestCheckResourceAttr(
"tfe_workspace.foobar", "operations", "true"),
resource.TestCheckResourceAttr(
"tfe_workspace.foobar", "trigger_prefixes.#", "2"),
resource.TestCheckResourceAttr(
Expand Down Expand Up @@ -173,6 +177,8 @@ func TestAccTFEWorkspace_renamed(t *testing.T) {
"tfe_workspace.foobar", "name", "workspace-test"),
resource.TestCheckResourceAttr(
"tfe_workspace.foobar", "auto_apply", "true"),
resource.TestCheckResourceAttr(
"tfe_workspace.foobar", "operations", "true"),
resource.TestCheckResourceAttr(
"tfe_workspace.foobar", "queue_all_runs", "true"),
resource.TestCheckResourceAttr(
Expand All @@ -192,6 +198,8 @@ func TestAccTFEWorkspace_renamed(t *testing.T) {
"tfe_workspace.foobar", "name", "workspace-test"),
resource.TestCheckResourceAttr(
"tfe_workspace.foobar", "auto_apply", "true"),
resource.TestCheckResourceAttr(
"tfe_workspace.foobar", "operations", "true"),
resource.TestCheckResourceAttr(
"tfe_workspace.foobar", "queue_all_runs", "true"),
resource.TestCheckResourceAttr(
Expand Down Expand Up @@ -219,6 +227,8 @@ func TestAccTFEWorkspace_update(t *testing.T) {
"tfe_workspace.foobar", "name", "workspace-test"),
resource.TestCheckResourceAttr(
"tfe_workspace.foobar", "auto_apply", "true"),
resource.TestCheckResourceAttr(
"tfe_workspace.foobar", "operations", "true"),
resource.TestCheckResourceAttr(
"tfe_workspace.foobar", "queue_all_runs", "true"),
resource.TestCheckResourceAttr(
Expand All @@ -238,6 +248,8 @@ func TestAccTFEWorkspace_update(t *testing.T) {
"tfe_workspace.foobar", "auto_apply", "false"),
resource.TestCheckResourceAttr(
"tfe_workspace.foobar", "file_triggers_enabled", "true"),
resource.TestCheckResourceAttr(
"tfe_workspace.foobar", "operations", "false"),
resource.TestCheckResourceAttr(
"tfe_workspace.foobar", "queue_all_runs", "false"),
resource.TestCheckResourceAttr(
Expand Down Expand Up @@ -397,6 +409,10 @@ func testAccCheckTFEWorkspaceAttributes(
return fmt.Errorf("Bad auto apply: %t", workspace.AutoApply)
}

if workspace.Operations != true {
return fmt.Errorf("Bad operations: %t", workspace.Operations)
}

if workspace.QueueAllRuns != true {
return fmt.Errorf("Bad queue all runs: %t", workspace.QueueAllRuns)
}
Expand Down Expand Up @@ -471,6 +487,10 @@ func testAccCheckTFEWorkspaceAttributesUpdated(
return fmt.Errorf("Bad auto apply: %t", workspace.AutoApply)
}

if workspace.Operations != false {
return fmt.Errorf("Bad operations: %t", workspace.Operations)
}

if workspace.QueueAllRuns != false {
return fmt.Errorf("Bad queue all runs: %t", workspace.QueueAllRuns)
}
Expand Down
129 changes: 129 additions & 0 deletions vendor/github.com/hashicorp/go-tfe/cost_estimate.go

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

7 changes: 7 additions & 0 deletions vendor/github.com/hashicorp/go-tfe/organization.go

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

3 changes: 3 additions & 0 deletions vendor/github.com/hashicorp/go-tfe/run.go

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

2 changes: 2 additions & 0 deletions vendor/github.com/hashicorp/go-tfe/tfe.go

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

Loading