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

Adds description parameter to TFE Workspace #271

Merged
merged 1 commit into from
Apr 20, 2021
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
1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.m
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjrss6TZTdY2VfCqZPbv5k3iBFa2ZQ=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0=
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
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 @@ -24,6 +24,11 @@ func dataSourceTFEWorkspace() *schema.Resource {
Required: true,
},

"description": {
Type: schema.TypeString,
Computed: true,
},

"allow_destroy_plan": {
Type: schema.TypeBool,
Computed: true,
Expand Down Expand Up @@ -146,6 +151,7 @@ func dataSourceTFEWorkspaceRead(d *schema.ResourceData, meta interface{}) error
// Update the config.
d.Set("allow_destroy_plan", workspace.AllowDestroyPlan)
d.Set("auto_apply", workspace.AutoApply)
d.Set("description", workspace.Description)
d.Set("file_triggers_enabled", workspace.FileTriggersEnabled)
d.Set("operations", workspace.Operations)
d.Set("queue_all_runs", workspace.QueueAllRuns)
Expand Down
3 changes: 3 additions & 0 deletions tfe/data_source_workspace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ func TestAccTFEWorkspaceDataSource_basic(t *testing.T) {
"data.tfe_workspace.foobar", "name", fmt.Sprintf("workspace-test-%d", rInt)),
resource.TestCheckResourceAttr(
"data.tfe_workspace.foobar", "organization", orgName),
resource.TestCheckResourceAttr(
"data.tfe_workspace.foobar", "description", "provider-testing"),
resource.TestCheckResourceAttr(
"data.tfe_workspace.foobar", "allow_destroy_plan", "false"),
resource.TestCheckResourceAttr(
Expand Down Expand Up @@ -67,6 +69,7 @@ resource "tfe_organization" "foobar" {
resource "tfe_workspace" "foobar" {
name = "workspace-test-%d"
organization = tfe_organization.foobar.id
description = "provider-testing"
allow_destroy_plan = false
auto_apply = true
file_triggers_enabled = true
Expand Down
11 changes: 10 additions & 1 deletion tfe/resource_tfe_workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ func resourceTFEWorkspace() *schema.Resource {
ForceNew: true,
},

"description": {
Type: schema.TypeString,
Optional: true,
},

"agent_pool_id": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -180,6 +185,7 @@ func resourceTFEWorkspaceCreate(d *schema.ResourceData, meta interface{}) error
Name: tfe.String(name),
AllowDestroyPlan: tfe.Bool(d.Get("allow_destroy_plan").(bool)),
AutoApply: tfe.Bool(d.Get("auto_apply").(bool)),
Description: tfe.String(d.Get("description").(string)),
FileTriggersEnabled: tfe.Bool(d.Get("file_triggers_enabled").(bool)),
QueueAllRuns: tfe.Bool(d.Get("queue_all_runs").(bool)),
SpeculativeEnabled: tfe.Bool(d.Get("speculative_enabled").(bool)),
Expand Down Expand Up @@ -267,6 +273,7 @@ func resourceTFEWorkspaceRead(d *schema.ResourceData, meta interface{}) error {
d.Set("name", workspace.Name)
d.Set("allow_destroy_plan", workspace.AllowDestroyPlan)
d.Set("auto_apply", workspace.AutoApply)
d.Set("description", workspace.Description)
d.Set("file_triggers_enabled", workspace.FileTriggersEnabled)
d.Set("operations", workspace.Operations)
d.Set("execution_mode", workspace.ExecutionMode)
Expand Down Expand Up @@ -315,13 +322,15 @@ func resourceTFEWorkspaceUpdate(d *schema.ResourceData, meta interface{}) error
d.HasChange("terraform_version") || d.HasChange("working_directory") || d.HasChange("vcs_repo") ||
d.HasChange("file_triggers_enabled") || d.HasChange("trigger_prefixes") ||
d.HasChange("allow_destroy_plan") || d.HasChange("speculative_enabled") ||
d.HasChange("operations") || d.HasChange("execution_mode") || d.HasChange("agent_pool_id") {
d.HasChange("operations") || d.HasChange("execution_mode") ||
d.HasChange("description") || d.HasChange("agent_pool_id") {

// Create a new options struct.
options := tfe.WorkspaceUpdateOptions{
Name: tfe.String(d.Get("name").(string)),
AllowDestroyPlan: tfe.Bool(d.Get("allow_destroy_plan").(bool)),
AutoApply: tfe.Bool(d.Get("auto_apply").(bool)),
Description: tfe.String(d.Get("description").(string)),
FileTriggersEnabled: tfe.Bool(d.Get("file_triggers_enabled").(bool)),
QueueAllRuns: tfe.Bool(d.Get("queue_all_runs").(bool)),
SpeculativeEnabled: tfe.Bool(d.Get("speculative_enabled").(bool)),
Expand Down
8 changes: 8 additions & 0 deletions tfe/resource_tfe_workspace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ func TestAccTFEWorkspace_basic(t *testing.T) {
testAccCheckTFEWorkspaceAttributes(workspace),
resource.TestCheckResourceAttr(
"tfe_workspace.foobar", "name", "workspace-test"),
resource.TestCheckResourceAttr(
"tfe_workspace.foobar", "description", "My favorite workspace!"),
resource.TestCheckResourceAttr(
"tfe_workspace.foobar", "allow_destroy_plan", "false"),
resource.TestCheckResourceAttr(
Expand Down Expand Up @@ -127,6 +129,8 @@ func TestAccTFEWorkspace_renamed(t *testing.T) {
testAccCheckTFEWorkspaceAttributes(workspace),
resource.TestCheckResourceAttr(
"tfe_workspace.foobar", "name", "workspace-test"),
resource.TestCheckResourceAttr(
"tfe_workspace.foobar", "description", "My favorite workspace!"),
resource.TestCheckResourceAttr(
"tfe_workspace.foobar", "allow_destroy_plan", "false"),
resource.TestCheckResourceAttr(
Expand All @@ -150,6 +154,8 @@ func TestAccTFEWorkspace_renamed(t *testing.T) {
testAccCheckTFEWorkspaceAttributes(workspace),
resource.TestCheckResourceAttr(
"tfe_workspace.foobar", "name", "workspace-test"),
resource.TestCheckResourceAttr(
"tfe_workspace.foobar", "description", "My favorite workspace!"),
resource.TestCheckResourceAttr(
"tfe_workspace.foobar", "allow_destroy_plan", "false"),
resource.TestCheckResourceAttr(
Expand Down Expand Up @@ -980,6 +986,7 @@ resource "tfe_organization" "foobar" {
resource "tfe_workspace" "foobar" {
name = "workspace-test"
organization = tfe_organization.foobar.id
description = "My favorite workspace!"
allow_destroy_plan = false
auto_apply = true
}`, rInt)
Expand Down Expand Up @@ -1117,6 +1124,7 @@ resource "tfe_organization" "foobar" {
resource "tfe_workspace" "foobar" {
name = "renamed-out-of-band"
organization = tfe_organization.foobar.id
description = "My favorite workspace!"
allow_destroy_plan = false
auto_apply = true
}`, rInt)
Expand Down