Skip to content

Commit

Permalink
Add descrip[tion field to Orgnanization Run Task
Browse files Browse the repository at this point in the history
  • Loading branch information
glennsarti committed Aug 2, 2022
1 parent bdb7444 commit 1a999a9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
21 changes: 15 additions & 6 deletions tfe/resource_tfe_organization_run_task.go
Expand Up @@ -56,6 +56,11 @@ func resourceTFEOrganizationRunTask() *schema.Resource {
Default: true,
Optional: true,
},

"description": {
Type: schema.TypeString,
Optional: true,
},
},
}
}
Expand All @@ -69,11 +74,12 @@ func resourceTFEOrganizationRunTaskCreate(d *schema.ResourceData, meta interface

// Create a new options struct.
options := tfe.RunTaskCreateOptions{
Name: name,
URL: d.Get("url").(string),
Category: d.Get("category").(string),
HMACKey: tfe.String(d.Get("hmac_key").(string)),
Enabled: tfe.Bool(d.Get("enabled").(bool)),
Name: name,
URL: d.Get("url").(string),
Category: d.Get("category").(string),
HMACKey: tfe.String(d.Get("hmac_key").(string)),
Enabled: tfe.Bool(d.Get("enabled").(bool)),
Description: tfe.String(d.Get("description").(string)),
}

log.Printf("[DEBUG] Create task %s for organization: %s", name, organization)
Expand Down Expand Up @@ -123,6 +129,9 @@ func resourceTFEOrganizationRunTaskUpdate(d *schema.ResourceData, meta interface
if d.HasChange("hmac_key") {
options.HMACKey = tfe.String(d.Get("hmac_key").(string))
}
if d.HasChange("description") {
options.Description = tfe.String(d.Get("description").(string))
}

log.Printf("[DEBUG] Update configuration of task: %s", d.Id())
task, err := tfeClient.RunTasks.Update(ctx, d.Id(), options)
Expand Down Expand Up @@ -158,7 +167,7 @@ func resourceTFEOrganizationRunTaskRead(d *schema.ResourceData, meta interface{}
// The HMAC Key is always empty from the API so all we can do is
// echo the request's key to the response
d.Set("hmac_key", tfe.String(d.Get("hmac_key").(string)))

d.Set("description", task.Description)
return nil
}

Expand Down
3 changes: 3 additions & 0 deletions tfe/resource_tfe_organization_run_task_test.go
Expand Up @@ -56,6 +56,7 @@ func TestAccTFEOrganizationRunTask_create(t *testing.T) {
resource.TestCheckResourceAttr("tfe_organization_run_task.foobar", "category", "task"),
resource.TestCheckResourceAttr("tfe_organization_run_task.foobar", "hmac_key", ""),
resource.TestCheckResourceAttr("tfe_organization_run_task.foobar", "enabled", "false"),
resource.TestCheckResourceAttr("tfe_organization_run_task.foobar", "description", ""),
),
},
{
Expand All @@ -66,6 +67,7 @@ func TestAccTFEOrganizationRunTask_create(t *testing.T) {
resource.TestCheckResourceAttr("tfe_organization_run_task.foobar", "category", "task"),
resource.TestCheckResourceAttr("tfe_organization_run_task.foobar", "hmac_key", "somepassword"),
resource.TestCheckResourceAttr("tfe_organization_run_task.foobar", "enabled", "true"),
resource.TestCheckResourceAttr("tfe_organization_run_task.foobar", "description", "a description"),
),
},
},
Expand Down Expand Up @@ -175,6 +177,7 @@ func testAccTFEOrganizationRunTask_update(orgName string, rInt int, runTaskURL s
name = "foobar-task-%d-new"
enabled = true
hmac_key = "somepassword"
description = "a description"
}
`, orgName, runTaskURL, rInt)
}

0 comments on commit 1a999a9

Please sign in to comment.