From 8e7673d99503a4f868b5e8c4ec32efb0de20ce7d Mon Sep 17 00:00:00 2001 From: Netra Mali Date: Fri, 1 Mar 2024 09:29:54 -0500 Subject: [PATCH 01/10] description to data source and resource --- internal/provider/data_source_project.go | 6 ++++++ internal/provider/data_source_project_test.go | 3 +++ internal/provider/resource_tfe_project.go | 12 ++++++++++-- internal/provider/resource_tfe_project_test.go | 8 ++++++++ 4 files changed, 27 insertions(+), 2 deletions(-) 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..792d53601 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", fmt.Sprintf("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) } From 0f8763de37e8caa9f09ecb6df8a1dc478a2e1774 Mon Sep 17 00:00:00 2001 From: Netra Mali Date: Fri, 1 Mar 2024 09:53:05 -0500 Subject: [PATCH 02/10] changelog, documentation --- CHANGELOG.md | 4 ++++ website/docs/r/project.html.markdown | 1 + 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3150c73a5..7fc9e04a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## UNRELEASED +ENHANCEMENTS: +* `r/tfe_project`: Add `description` attribute, by @netramali [1270](https://github.com/hashicorp/terraform-provider-tfe/pull/1270) +* `d/tfe_project`: Add `description` attribute, by @netramali [1270](https://github.com/hashicorp/terraform-provider-tfe/pull/1270) + 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) 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 From df66c90a776addb06c47079301989d0aeba70c5e Mon Sep 17 00:00:00 2001 From: Netra Mali <104793044+netramali@users.noreply.github.com> Date: Fri, 1 Mar 2024 09:59:19 -0500 Subject: [PATCH 03/10] Update CHANGELOG.md --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fc9e04a7..8c3ce5b36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,8 @@ ## UNRELEASED ENHANCEMENTS: -* `r/tfe_project`: Add `description` attribute, by @netramali [1270](https://github.com/hashicorp/terraform-provider-tfe/pull/1270) -* `d/tfe_project`: Add `description` attribute, by @netramali [1270](https://github.com/hashicorp/terraform-provider-tfe/pull/1270) +* `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) From 925ff845da64c62c0a805e1c8a7256237d6c2e72 Mon Sep 17 00:00:00 2001 From: Netra Mali Date: Fri, 1 Mar 2024 10:38:38 -0500 Subject: [PATCH 04/10] skip tests - feature is still feature flagged --- internal/provider/data_source_project_test.go | 1 + internal/provider/resource_tfe_project_test.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/internal/provider/data_source_project_test.go b/internal/provider/data_source_project_test.go index 792d53601..2e9393298 100644 --- a/internal/provider/data_source_project_test.go +++ b/internal/provider/data_source_project_test.go @@ -13,6 +13,7 @@ import ( ) func TestAccTFEProjectDataSource_basic(t *testing.T) { + skipUnlessBeta(t) rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int() orgName := fmt.Sprintf("tst-terraform-%d", rInt) diff --git a/internal/provider/resource_tfe_project_test.go b/internal/provider/resource_tfe_project_test.go index e77f03ea7..faea2bb7f 100644 --- a/internal/provider/resource_tfe_project_test.go +++ b/internal/provider/resource_tfe_project_test.go @@ -17,6 +17,7 @@ import ( ) func TestAccTFEProject_basic(t *testing.T) { + skipUnlessBeta(t) project := &tfe.Project{} rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int() @@ -64,6 +65,7 @@ func TestAccTFEProject_invalidName(t *testing.T) { } func TestAccTFEProject_update(t *testing.T) { + skipUnlessBeta(t) project := &tfe.Project{} rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int() From 449e69345fd3bff0870c7e1585dd6961d6e39246 Mon Sep 17 00:00:00 2001 From: Netra Mali <104793044+netramali@users.noreply.github.com> Date: Tue, 12 Mar 2024 16:20:08 -0400 Subject: [PATCH 05/10] Update data_source_project_test.go --- internal/provider/data_source_project_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/provider/data_source_project_test.go b/internal/provider/data_source_project_test.go index 2e9393298..463f7de3a 100644 --- a/internal/provider/data_source_project_test.go +++ b/internal/provider/data_source_project_test.go @@ -27,7 +27,7 @@ func TestAccTFEProjectDataSource_basic(t *testing.T) { resource.TestCheckResourceAttr( "data.tfe_project.foobar", "name", fmt.Sprintf("project-test-%d", rInt)), resource.TestCheckResourceAttr( - "data.tfe_project.foobar", "description", fmt.Sprintf("project description")), + "data.tfe_project.foobar", "description", "project description"), resource.TestCheckResourceAttr( "data.tfe_project.foobar", "organization", orgName), resource.TestCheckResourceAttrSet("data.tfe_project.foobar", "id"), From 2d7e11fad675730bbc58872c4f3949ed3370eadb Mon Sep 17 00:00:00 2001 From: Netra Mali <104793044+netramali@users.noreply.github.com> Date: Wed, 13 Mar 2024 09:47:59 -0400 Subject: [PATCH 06/10] Update resource_tfe_project_test.go --- internal/provider/resource_tfe_project_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/provider/resource_tfe_project_test.go b/internal/provider/resource_tfe_project_test.go index faea2bb7f..f2349bcdc 100644 --- a/internal/provider/resource_tfe_project_test.go +++ b/internal/provider/resource_tfe_project_test.go @@ -103,6 +103,7 @@ func TestAccTFEProject_update(t *testing.T) { } func TestAccTFEProject_import(t *testing.T) { + skipUnlessBeta(t) rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int() project := &tfe.Project{} resource.Test(t, resource.TestCase{ From 9c8551dfc21ae4e0da88b73138024ab4f436100a Mon Sep 17 00:00:00 2001 From: Netra Mali <104793044+netramali@users.noreply.github.com> Date: Wed, 13 Mar 2024 10:23:55 -0400 Subject: [PATCH 07/10] Update CHANGELOG.md Co-authored-by: Mark DeCrane --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a3e39b602..c03dfc029 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,6 @@ 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) From 8eaf036093547ca2fbb7298cc6ec62683c3c462e Mon Sep 17 00:00:00 2001 From: Netra Mali <104793044+netramali@users.noreply.github.com> Date: Wed, 13 Mar 2024 10:36:01 -0400 Subject: [PATCH 08/10] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c03dfc029..a3e39b602 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ 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) From 0b2089710f6c4e0ecedda35d46cda9a4d4d189df Mon Sep 17 00:00:00 2001 From: Netra Mali <104793044+netramali@users.noreply.github.com> Date: Wed, 10 Apr 2024 11:00:09 -0400 Subject: [PATCH 09/10] Update data_source_project_test.go --- internal/provider/data_source_project_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/provider/data_source_project_test.go b/internal/provider/data_source_project_test.go index 463f7de3a..0af8c0bb6 100644 --- a/internal/provider/data_source_project_test.go +++ b/internal/provider/data_source_project_test.go @@ -13,7 +13,6 @@ import ( ) func TestAccTFEProjectDataSource_basic(t *testing.T) { - skipUnlessBeta(t) rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int() orgName := fmt.Sprintf("tst-terraform-%d", rInt) From 4384dfed9de01c3a0a84c8660f48e19b7355aef0 Mon Sep 17 00:00:00 2001 From: Netra Mali Date: Wed, 10 Apr 2024 11:31:25 -0400 Subject: [PATCH 10/10] beta test --- internal/provider/resource_tfe_project_test.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/internal/provider/resource_tfe_project_test.go b/internal/provider/resource_tfe_project_test.go index f2349bcdc..e77f03ea7 100644 --- a/internal/provider/resource_tfe_project_test.go +++ b/internal/provider/resource_tfe_project_test.go @@ -17,7 +17,6 @@ import ( ) func TestAccTFEProject_basic(t *testing.T) { - skipUnlessBeta(t) project := &tfe.Project{} rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int() @@ -65,7 +64,6 @@ func TestAccTFEProject_invalidName(t *testing.T) { } func TestAccTFEProject_update(t *testing.T) { - skipUnlessBeta(t) project := &tfe.Project{} rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int() @@ -103,7 +101,6 @@ func TestAccTFEProject_update(t *testing.T) { } func TestAccTFEProject_import(t *testing.T) { - skipUnlessBeta(t) rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int() project := &tfe.Project{} resource.Test(t, resource.TestCase{