Skip to content

Commit

Permalink
Merge pull request #1271 from hashicorp/netramali/TF-11504-add-descri…
Browse files Browse the repository at this point in the history
…ption-to-projects

TF-11504 add description to projects
  • Loading branch information
netramali committed Apr 23, 2024
2 parents 0706390 + a0353a4 commit d2e4c2a
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions internal/provider/data_source_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ func dataSourceTFEProject() *schema.Resource {
Required: true,
},

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

"organization": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -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
}
Expand Down
3 changes: 3 additions & 0 deletions internal/provider/data_source_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -67,6 +69,7 @@ resource "tfe_organization" "foobar" {
resource "tfe_project" "foobar" {
name = "project-test-%d"
description = "project description"
organization = tfe_organization.foobar.id
}
Expand Down
12 changes: 10 additions & 2 deletions internal/provider/resource_tfe_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ func resourceTFEProject() *schema.Resource {
),
},

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

"organization": {
Type: schema.TypeString,
Optional: true,
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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())
Expand Down
8 changes: 8 additions & 0 deletions internal/provider/resource_tfe_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
),
Expand Down Expand Up @@ -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"),
),
},
{
Expand All @@ -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"),
),
},
},
Expand Down Expand Up @@ -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)
}

Expand All @@ -146,6 +153,7 @@ resource "tfe_organization" "foobar" {
resource "tfe_project" "foobar" {
organization = tfe_organization.foobar.name
name = "projecttest"
description = "project description"
}`, rInt)
}

Expand Down
1 change: 1 addition & 0 deletions website/docs/r/project.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit d2e4c2a

Please sign in to comment.