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

fix bug where overridable is not updated #594

Merged
merged 5 commits into from Nov 28, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,10 @@
# Unreleased

## Enhancements

* Adds Beta parameter `Overridable` for OPA `policy set` update API (`PolicySetUpdateOptions`) @mrinalirao [#594](https://github.com/hashicorp/go-tfe/pull/594)
* Adds new task stage status values representing `canceled`, `errored`, `unreachable` @mrinalirao [#594](https://github.com/hashicorp/go-tfe/pull/594)

# v1.13.0

## Bug Fixes
Expand Down
4 changes: 4 additions & 0 deletions policy_set.go
Expand Up @@ -195,6 +195,10 @@ type PolicySetUpdateOptions struct {
// Optional: Whether or not the policy set is global.
Global *bool `jsonapi:"attr,global,omitempty"`

// **Note: This field is still in BETA and subject to change.**
// Optional: Whether or not users can override this policy when it fails during a run. Only valid for OPA policies.
Overridable *bool `jsonapi:"attr,overridable,omitempty"`

// Optional: The sub-path within the attached VCS repository to ingress. All
// files and directories outside of this sub-path will be ignored.
// This option may only be specified when a VCS repo is present.
Expand Down
33 changes: 33 additions & 0 deletions policy_set_integration_beta_test.go
Expand Up @@ -331,3 +331,36 @@ func TestPolicySetsCreate_Beta(t *testing.T) {
assert.EqualError(t, err, ErrInvalidOrg.Error())
})
}

func TestPolicySetsUpdate_Beta(t *testing.T) {
skipIfFreeOnly(t)
skipIfBeta(t)

client := testClient(t)
ctx := context.Background()

orgTest, orgTestCleanup := createOrganization(t, client)
defer orgTestCleanup()

upgradeOrganizationSubscription(t, client, orgTest)

psTest, psTestCleanup := createPolicySet(t, client, orgTest, nil, nil, "opa")
defer psTestCleanup()

t.Run("with valid attributes", func(t *testing.T) {
options := PolicySetUpdateOptions{
Name: String("global"),
Description: String("Policies in this set will be checked in ALL workspaces!"),
Global: Bool(true),
Overridable: Bool(true),
}

ps, err := client.PolicySets.Update(ctx, psTest.ID, options)
require.NoError(t, err)

assert.Equal(t, ps.Name, *options.Name)
assert.Equal(t, ps.Description, *options.Description)
assert.True(t, ps.Global)
assert.True(t, *ps.Overridable)
})
}
3 changes: 3 additions & 0 deletions task_stages.go
Expand Up @@ -46,6 +46,9 @@ const (
TaskStagePassed TaskStageStatus = "passed"
TaskStageFailed TaskStageStatus = "failed"
TaskStageAwaitingOverride TaskStageStatus = "awaiting_override"
TaskStageCanceled TaskStageStatus = "canceled"
TaskStageErrored TaskStageStatus = "errored"
TaskStageUnreachable TaskStageStatus = "unreachable"
)

// Permissions represents the permission types for overridding a task stage
Expand Down