diff --git a/CHANGELOG.md b/CHANGELOG.md index 702242a20..bbd82b07d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ ## v0.53.0 +ENHANCEMENTS: +* `r/tfe_project`: Add `description` attribute, by @netramali [1271](https://github.com/hashicorp/terraform-provider-tfe/pull/1271) +* `d/tfe_project`: Add `description` attribute, by @netramali [1271](https://github.com/hashicorp/terraform-provider-tfe/pull/1271) + FEATURES: * `r/tfe_workspace`: Add `ignore_additional_tag_names` which explicitly ignores `tag_names` _not_ defined by config so they will not be overwritten by the configured tags, by @brandonc and @mbillow [1254](https://github.com/hashicorp/terraform-provider-tfe/pull/1254) * `r/tfe_oauth_client`: Add `organization_scoped` attribute, by @Netra2104 [1142](https://github.com/hashicorp/terraform-provider-tfe/pull/1142) diff --git a/internal/provider/data_source_project.go b/internal/provider/data_source_project.go index e4c9cf99a..07a1c9b1d 100644 --- a/internal/provider/data_source_project.go +++ b/internal/provider/data_source_project.go @@ -28,6 +28,11 @@ func dataSourceTFEProject() *schema.Resource { Required: true, }, + "description": { + Type: schema.TypeString, + Computed: true, + }, + "organization": { Type: schema.TypeString, Optional: true, @@ -92,6 +97,7 @@ func dataSourceTFEProjectRead(ctx context.Context, d *schema.ResourceData, meta } d.Set("workspace_ids", workspaces) + d.Set("description", proj.Description) d.SetId(proj.ID) return nil } diff --git a/internal/provider/data_source_project_test.go b/internal/provider/data_source_project_test.go index a6fd442ba..0af8c0bb6 100644 --- a/internal/provider/data_source_project_test.go +++ b/internal/provider/data_source_project_test.go @@ -25,6 +25,8 @@ func TestAccTFEProjectDataSource_basic(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr( "data.tfe_project.foobar", "name", fmt.Sprintf("project-test-%d", rInt)), + resource.TestCheckResourceAttr( + "data.tfe_project.foobar", "description", "project description"), resource.TestCheckResourceAttr( "data.tfe_project.foobar", "organization", orgName), resource.TestCheckResourceAttrSet("data.tfe_project.foobar", "id"), @@ -67,6 +69,7 @@ resource "tfe_organization" "foobar" { resource "tfe_project" "foobar" { name = "project-test-%d" + description = "project description" organization = tfe_organization.foobar.id } diff --git a/internal/provider/resource_tfe_project.go b/internal/provider/resource_tfe_project.go index 2762c5c47..5bc155c8d 100644 --- a/internal/provider/resource_tfe_project.go +++ b/internal/provider/resource_tfe_project.go @@ -46,6 +46,11 @@ func resourceTFEProject() *schema.Resource { ), }, + "description": { + Type: schema.TypeString, + Optional: true, + }, + "organization": { Type: schema.TypeString, Optional: true, @@ -66,7 +71,8 @@ func resourceTFEProjectCreate(ctx context.Context, d *schema.ResourceData, meta name := d.Get("name").(string) options := tfe.ProjectCreateOptions{ - Name: name, + Name: name, + Description: tfe.String(d.Get("description").(string)), } log.Printf("[DEBUG] Create new project: %s", name) @@ -95,6 +101,7 @@ func resourceTFEProjectRead(ctx context.Context, d *schema.ResourceData, meta in } d.Set("name", project.Name) + d.Set("description", project.Description) d.Set("organization", project.Organization.Name) return nil @@ -104,7 +111,8 @@ func resourceTFEProjectUpdate(ctx context.Context, d *schema.ResourceData, meta config := meta.(ConfiguredClient) options := tfe.ProjectUpdateOptions{ - Name: tfe.String(d.Get("name").(string)), + Name: tfe.String(d.Get("name").(string)), + Description: tfe.String(d.Get("description").(string)), } log.Printf("[DEBUG] Update configuration of project: %s", d.Id()) diff --git a/internal/provider/resource_tfe_project_test.go b/internal/provider/resource_tfe_project_test.go index 0dd424ae6..e77f03ea7 100644 --- a/internal/provider/resource_tfe_project_test.go +++ b/internal/provider/resource_tfe_project_test.go @@ -33,6 +33,8 @@ func TestAccTFEProject_basic(t *testing.T) { testAccCheckTFEProjectAttributes(project), resource.TestCheckResourceAttr( "tfe_project.foobar", "name", "projecttest"), + resource.TestCheckResourceAttr( + "tfe_project.foobar", "description", "project description"), resource.TestCheckResourceAttr( "tfe_project.foobar", "organization", fmt.Sprintf("tst-terraform-%d", rInt)), ), @@ -78,6 +80,8 @@ func TestAccTFEProject_update(t *testing.T) { testAccCheckTFEProjectAttributes(project), resource.TestCheckResourceAttr( "tfe_project.foobar", "name", "projecttest"), + resource.TestCheckResourceAttr( + "tfe_project.foobar", "description", "project description"), ), }, { @@ -88,6 +92,8 @@ func TestAccTFEProject_update(t *testing.T) { testAccCheckTFEProjectAttributesUpdated(project), resource.TestCheckResourceAttr( "tfe_project.foobar", "name", "project updated"), + resource.TestCheckResourceAttr( + "tfe_project.foobar", "description", "project description updated"), ), }, }, @@ -133,6 +139,7 @@ resource "tfe_organization" "foobar" { resource "tfe_project" "foobar" { organization = tfe_organization.foobar.name name = "project updated" + description = "project description updated" }`, rInt) } @@ -146,6 +153,7 @@ resource "tfe_organization" "foobar" { resource "tfe_project" "foobar" { organization = tfe_organization.foobar.name name = "projecttest" + description = "project description" }`, rInt) } diff --git a/website/docs/r/project.html.markdown b/website/docs/r/project.html.markdown index 40b419e5d..7c152ce85 100644 --- a/website/docs/r/project.html.markdown +++ b/website/docs/r/project.html.markdown @@ -31,6 +31,7 @@ The following arguments are supported: * `name` - (Required) Name of the project. * `organization` - (Optional) Name of the organization. If omitted, organization must be defined in the provider config. +* `description` - (Optional) A description for the project. ## Attributes Reference