Skip to content

Commit b4eca77

Browse files
authored
Merge pull request #594 from hashicorp/mr/policy-set-bug-fix
fix bug where overridable is not updated
2 parents 9f9c19e + 8d41a0f commit b4eca77

4 files changed

+47
-0
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# Unreleased
2+
3+
## Enhancements
4+
5+
* Adds Beta parameter `Overridable` for OPA `policy set` update API (`PolicySetUpdateOptions`) @mrinalirao [#594](https://github.com/hashicorp/go-tfe/pull/594)
6+
* Adds new task stage status values representing `canceled`, `errored`, `unreachable` @mrinalirao [#594](https://github.com/hashicorp/go-tfe/pull/594)
7+
18
# v1.13.0
29

310
## Bug Fixes

policy_set.go

+4
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ type PolicySetUpdateOptions struct {
195195
// Optional: Whether or not the policy set is global.
196196
Global *bool `jsonapi:"attr,global,omitempty"`
197197

198+
// **Note: This field is still in BETA and subject to change.**
199+
// Optional: Whether or not users can override this policy when it fails during a run. Only valid for OPA policies.
200+
Overridable *bool `jsonapi:"attr,overridable,omitempty"`
201+
198202
// Optional: The sub-path within the attached VCS repository to ingress. All
199203
// files and directories outside of this sub-path will be ignored.
200204
// This option may only be specified when a VCS repo is present.

policy_set_integration_beta_test.go

+33
Original file line numberDiff line numberDiff line change
@@ -331,3 +331,36 @@ func TestPolicySetsCreate_Beta(t *testing.T) {
331331
assert.EqualError(t, err, ErrInvalidOrg.Error())
332332
})
333333
}
334+
335+
func TestPolicySetsUpdate_Beta(t *testing.T) {
336+
skipIfFreeOnly(t)
337+
skipIfBeta(t)
338+
339+
client := testClient(t)
340+
ctx := context.Background()
341+
342+
orgTest, orgTestCleanup := createOrganization(t, client)
343+
defer orgTestCleanup()
344+
345+
upgradeOrganizationSubscription(t, client, orgTest)
346+
347+
psTest, psTestCleanup := createPolicySet(t, client, orgTest, nil, nil, "opa")
348+
defer psTestCleanup()
349+
350+
t.Run("with valid attributes", func(t *testing.T) {
351+
options := PolicySetUpdateOptions{
352+
Name: String("global"),
353+
Description: String("Policies in this set will be checked in ALL workspaces!"),
354+
Global: Bool(true),
355+
Overridable: Bool(true),
356+
}
357+
358+
ps, err := client.PolicySets.Update(ctx, psTest.ID, options)
359+
require.NoError(t, err)
360+
361+
assert.Equal(t, ps.Name, *options.Name)
362+
assert.Equal(t, ps.Description, *options.Description)
363+
assert.True(t, ps.Global)
364+
assert.True(t, *ps.Overridable)
365+
})
366+
}

task_stages.go

+3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ const (
4646
TaskStagePassed TaskStageStatus = "passed"
4747
TaskStageFailed TaskStageStatus = "failed"
4848
TaskStageAwaitingOverride TaskStageStatus = "awaiting_override"
49+
TaskStageCanceled TaskStageStatus = "canceled"
50+
TaskStageErrored TaskStageStatus = "errored"
51+
TaskStageUnreachable TaskStageStatus = "unreachable"
4952
)
5053

5154
// Permissions represents the permission types for overridding a task stage

0 commit comments

Comments
 (0)