Skip to content

Commit

Permalink
Merge pull request #594 from hashicorp/mr/policy-set-bug-fix
Browse files Browse the repository at this point in the history
fix bug where overridable is not updated
  • Loading branch information
mrinalirao committed Nov 28, 2022
2 parents 9f9c19e + 8d41a0f commit b4eca77
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
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

0 comments on commit b4eca77

Please sign in to comment.