From 8c28434d1547a7f060c46273b8734fc7a374fb6a Mon Sep 17 00:00:00 2001 From: mrinalirao Date: Thu, 24 Nov 2022 10:34:11 +1100 Subject: [PATCH 1/5] fix bug where overridable is not updated --- policy_set.go | 4 ++++ policy_set_integration_beta_test.go | 33 +++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/policy_set.go b/policy_set.go index 663c83484..c8a77950f 100644 --- a/policy_set.go +++ b/policy_set.go @@ -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. diff --git a/policy_set_integration_beta_test.go b/policy_set_integration_beta_test.go index ecbc7ac36..dcf98ef2b 100644 --- a/policy_set_integration_beta_test.go +++ b/policy_set_integration_beta_test.go @@ -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.Global) + }) +} From a17b4f13a8cff39b1bd207e43c8d72607f4e0db7 Mon Sep 17 00:00:00 2001 From: mrinalirao Date: Thu, 24 Nov 2022 10:39:12 +1100 Subject: [PATCH 2/5] add changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b39696027..fb0b2cb2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# Unreleased + +## Bug Fixes + +* Fixes `policy set` update api parameters (`Overridable`), which was not being set in the PolicySetUpdateOptions @mrinalirao [#594](https://github.com/hashicorp/go-tfe/pull/594) + # v1.13.0 ## Bug Fixes From 2940cebcc5f144d0b3128414a85ee78ee334d1fb Mon Sep 17 00:00:00 2001 From: mrinalirao Date: Thu, 24 Nov 2022 10:41:36 +1100 Subject: [PATCH 3/5] fix test --- policy_set_integration_beta_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/policy_set_integration_beta_test.go b/policy_set_integration_beta_test.go index dcf98ef2b..cffad1fba 100644 --- a/policy_set_integration_beta_test.go +++ b/policy_set_integration_beta_test.go @@ -361,6 +361,6 @@ func TestPolicySetsUpdate_Beta(t *testing.T) { assert.Equal(t, ps.Name, *options.Name) assert.Equal(t, ps.Description, *options.Description) assert.True(t, ps.Global) - assert.True(t, ps.Global) + assert.True(t, *ps.Overridable) }) } From 7f51e0f224d9b48344c75d925f957fed7f844c64 Mon Sep 17 00:00:00 2001 From: mrinalirao Date: Fri, 25 Nov 2022 15:23:44 +1100 Subject: [PATCH 4/5] add missing status required for cli implementation --- task_stages.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/task_stages.go b/task_stages.go index a707cbfce..90f2e569f 100644 --- a/task_stages.go +++ b/task_stages.go @@ -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 From 8d41a0f149d5c064e124c8bf54383490b9a9717f Mon Sep 17 00:00:00 2001 From: Mrinali Rao Date: Tue, 29 Nov 2022 08:34:42 +1100 Subject: [PATCH 5/5] Update CHANGELOG.md Co-authored-by: Brandon Croft --- CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb0b2cb2a..8e67a0033 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,9 @@ # Unreleased -## Bug Fixes +## Enhancements -* Fixes `policy set` update api parameters (`Overridable`), which was not being set in the PolicySetUpdateOptions @mrinalirao [#594](https://github.com/hashicorp/go-tfe/pull/594) +* 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