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-9651 update varset enforced attribute to priority attribute #779

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: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# UNRELEASED
## Features
* Added BETA support for including `priority` attribute to variable_set on create and update by @Netra2104 [#778](https://github.com/hashicorp/go-tfe/pull/778)

# v.1.37.0

Expand All @@ -20,7 +22,6 @@
* Added BETA support for private module registry tests by @hashimoon [#781](https://github.com/hashicorp/go-tfe/pull/781)

## Enhancements
* Added BETA support for including `enforced` attribute to variable_set on create and update by @Netra2104 [#778](https://github.com/hashicorp/go-tfe/pull/778)
* Removed beta flags for `PolicySetProjects` and `PolicySetWorkspaceExclusions` by @Netra2104 [#770](https://github.com/hashicorp/go-tfe/pull/770)

# v1.34.0
Expand Down
12 changes: 7 additions & 5 deletions variable_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ type VariableSet struct {
Description string `jsonapi:"attr,description"`
Global bool `jsonapi:"attr,global"`
// **Note: This field is still in BETA and subject to change.**
Enforced bool `jsonapi:"attr,enforced"`
Priority bool `jsonapi:"attr,priority"`

// Relations
Organization *Organization `jsonapi:"relation,organization"`
Expand Down Expand Up @@ -117,8 +117,9 @@ type VariableSetCreateOptions struct {
Global *bool `jsonapi:"attr,global,omitempty"`

// **Note: This field is still in BETA and subject to change.**
// If true the variables in the set cannot be overwritten and take precedence.
Enforced *bool `jsonapi:"attr,enforced,omitempty"`
// If true the variables in the set override any other variable values set
// in a more specific scope including values set on the command line.
Priority *bool `jsonapi:"attr,priority,omitempty"`
}

// VariableSetReadOptions represents the options for reading variable sets.
Expand Down Expand Up @@ -146,8 +147,9 @@ type VariableSetUpdateOptions struct {
Global *bool `jsonapi:"attr,global,omitempty"`

// **Note: This field is still in BETA and subject to change.**
// If true the variables in the set cannot be overwritten and take precedence.
Enforced *bool `jsonapi:"attr,enforced,omitempty"`
// If true the variables in the set override any other variable values set
// in a more specific scope including values set on the command line.
Priority *bool `jsonapi:"attr,priority,omitempty"`
}

// VariableSetApplyToWorkspacesOptions represents the options for applying variable sets to workspaces.
Expand Down
16 changes: 8 additions & 8 deletions variable_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func TestVariableSetsCreate(t *testing.T) {
})
}

func TestVariableSetsWithEnforcedCreate(t *testing.T) {
func TestVariableSetsWithPriorityCreate(t *testing.T) {
skipUnlessBeta(t)
client := testClient(t)
ctx := context.Background()
Expand All @@ -221,7 +221,7 @@ func TestVariableSetsWithEnforcedCreate(t *testing.T) {
Name: String("varset"),
Description: String("a variable set"),
Global: Bool(false),
Enforced: Bool(false),
Priority: Bool(false),
}

vs, err := client.VariableSets.Create(ctx, orgTest.Name, &options)
Expand All @@ -239,7 +239,7 @@ func TestVariableSetsWithEnforcedCreate(t *testing.T) {
assert.Equal(t, *options.Name, item.Name)
assert.Equal(t, *options.Description, item.Description)
assert.Equal(t, *options.Global, item.Global)
assert.Equal(t, *options.Enforced, item.Enforced)
assert.Equal(t, *options.Priority, item.Priority)
}
})

Expand Down Expand Up @@ -322,7 +322,7 @@ func TestVariableSetsUpdate(t *testing.T) {
})
}

func TestVariableSetsUpdateWithEnforced(t *testing.T) {
func TestVariableSetsUpdateWithPriority(t *testing.T) {
skipUnlessBeta(t)
client := testClient(t)
ctx := context.Background()
Expand All @@ -334,15 +334,15 @@ func TestVariableSetsUpdateWithEnforced(t *testing.T) {
Name: String("OriginalName"),
Description: String("Original Description"),
Global: Bool(false),
Enforced: Bool(false),
Priority: Bool(false),
})

t.Run("when updating a subset of values", func(t *testing.T) {
options := VariableSetUpdateOptions{
Name: String("UpdatedName"),
Description: String("Updated Description"),
Global: Bool(true),
Enforced: Bool(true),
Priority: Bool(true),
}

vsAfter, err := client.VariableSets.Update(ctx, vsTest.ID, &options)
Expand All @@ -351,15 +351,15 @@ func TestVariableSetsUpdateWithEnforced(t *testing.T) {
assert.Equal(t, *options.Name, vsAfter.Name)
assert.Equal(t, *options.Description, vsAfter.Description)
assert.Equal(t, *options.Global, vsAfter.Global)
assert.Equal(t, *options.Enforced, vsAfter.Enforced)
assert.Equal(t, *options.Priority, vsAfter.Priority)
})

t.Run("when options has an invalid variable set ID", func(t *testing.T) {
vsAfter, err := client.VariableSets.Update(ctx, badIdentifier, &VariableSetUpdateOptions{
Name: String("UpdatedName"),
Description: String("Updated Description"),
Global: Bool(true),
Enforced: Bool(true),
Priority: Bool(true),
})
assert.Nil(t, vsAfter)
assert.EqualError(t, err, ErrInvalidVariableSetID.Error())
Expand Down
Loading