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

TF-11505 Add description to project resource #861

Merged
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Unreleased

## Enhancements
* Adds `description` attribute to `Project` by @netramali [861](https://github.com/hashicorp/go-tfe/pull/861)

# v1.46.0

## Enhancements
Expand Down
11 changes: 11 additions & 0 deletions project.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ type Project struct {
ID string `jsonapi:"primary,projects"`
Name string `jsonapi:"attr,name"`

// **Note: This field is still in BETA and subject to change.**
Description string `jsonapi:"attr,description"`

// Relations
Organization *Organization `jsonapi:"relation,organization"`
}
Expand Down Expand Up @@ -76,6 +79,10 @@ type ProjectCreateOptions struct {

// Required: A name to identify the project.
Name string `jsonapi:"attr,name"`

// Optional: A description for the project.
// **Note: This field is still in BETA and subject to change.**
Description *string `jsonapi:"attr,description,omitempty"`
}

// ProjectUpdateOptions represents the options for updating a project
Expand All @@ -88,6 +95,10 @@ type ProjectUpdateOptions struct {

// Optional: A name to identify the project
Name *string `jsonapi:"attr,name,omitempty"`

// Optional: A description for the project.
// **Note: This field is still in BETA and subject to change.**
Description *string `jsonapi:"attr,description,omitempty"`
}

// List all projects.
Expand Down
10 changes: 8 additions & 2 deletions projects_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ func TestProjectsCreate(t *testing.T) {
defer orgTestCleanup()

t.Run("with valid options", func(t *testing.T) {
skipUnlessBeta(t)
options := ProjectCreateOptions{
Name: "foo",
Name: "foo",
Description: String("qux"),
}

w, err := client.Projects.Create(ctx, orgTest.Name, options)
Expand All @@ -118,6 +120,7 @@ func TestProjectsCreate(t *testing.T) {
} {
assert.NotEmpty(t, item.ID)
assert.Equal(t, options.Name, item.Name)
assert.Equal(t, *options.Description, item.Description)
}
})

Expand Down Expand Up @@ -152,16 +155,19 @@ func TestProjectsUpdate(t *testing.T) {
defer orgTestCleanup()

t.Run("with valid options", func(t *testing.T) {
skipUnlessBeta(t)
kBefore, kTestCleanup := createProject(t, client, orgTest)
defer kTestCleanup()

kAfter, err := client.Projects.Update(ctx, kBefore.ID, ProjectUpdateOptions{
Name: String("new project name"),
Name: String("new project name"),
Description: String("updated description"),
})
require.NoError(t, err)

assert.Equal(t, kBefore.ID, kAfter.ID)
assert.NotEqual(t, kBefore.Name, kAfter.Name)
assert.NotEqual(t, kBefore.Description, kAfter.Description)
})

t.Run("when updating with invalid name", func(t *testing.T) {
Expand Down
Loading