Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
* Improve API error handling to decode both JSON:API error objects and regular JSON errors arrays by @uk1288 [#1304](https://github.com/hashicorp/go-tfe/pull/1304)

## Enhancements

* Adds the `ProviderType` field to `AdminSAMLSetting` and `AdminSAMLSettingsUpdateOptions` to support the `provider-type` SAML setting by @skj-skj [#1303](https://github.com/hashicorp/go-tfe/pull/1303)
* Adds `AdminSCIMSetting` to support managing site-level SCIM settings by @skj-skj [#1307](https://github.com/hashicorp/go-tfe/pull/1307)
* Adds `PolicyUpdatePatterns` to `PolicySet`, `PolicySetCreateOptions`, and `PolicySetUpdateOptions` to support `policy-update-patterns` by @nithishravindra [#1306](https://github.com/hashicorp/go-tfe/pull/1306)

# v1.103.0

Expand Down
8 changes: 8 additions & 0 deletions policy_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ type PolicySet struct {
AgentEnabled bool `jsonapi:"attr,agent-enabled"`
PolicyToolVersion string `jsonapi:"attr,policy-tool-version"`

PolicyUpdatePatterns []string `jsonapi:"attr,policy-update-patterns"`

// Relations
// The organization to which the policy set belongs to.
Organization *Organization `jsonapi:"relation,organization"`
Expand Down Expand Up @@ -197,6 +199,9 @@ type PolicySetCreateOptions struct {
// Optional: The policy tool version to run the evaluation against.
PolicyToolVersion *string `jsonapi:"attr,policy-tool-version,omitempty"`

// Optional: A list of glob patterns that trigger policy set updates.
PolicyUpdatePatterns []string `jsonapi:"attr,policy-update-patterns,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 Expand Up @@ -252,6 +257,9 @@ type PolicySetUpdateOptions struct {
// Optional: The policy tool version to run the evaluation against.
PolicyToolVersion *string `jsonapi:"attr,policy-tool-version,omitempty"`

// Optional: A list of glob patterns that trigger policy set updates.
PolicyUpdatePatterns []string `jsonapi:"attr,policy-update-patterns,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
26 changes: 26 additions & 0 deletions policy_set_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,21 @@ func TestPolicySetsCreate(t *testing.T) {
assert.False(t, ps.Global)
})

t.Run("OPA policy set with policy update patterns", func(t *testing.T) {
options := PolicySetCreateOptions{
Name: String(randomString(t)),
Kind: OPA,
PolicyUpdatePatterns: []string{"*.rego", "policies/**"},
}

ps, err := client.PolicySets.Create(ctx, orgTest.Name, options)
require.NoError(t, err)

assert.Equal(t, ps.Name, *options.Name)
assert.Equal(t, ps.Kind, OPA)
assert.Equal(t, options.PolicyUpdatePatterns, ps.PolicyUpdatePatterns)
})

t.Run("with pinned policy runtime version valid attributes", func(t *testing.T) {
options := PolicySetCreateOptions{
Name: String(randomString(t)),
Expand Down Expand Up @@ -731,6 +746,17 @@ func TestPolicySetsUpdate(t *testing.T) {
assert.True(t, *ps.Overridable)
})

t.Run("with policy update patterns", func(t *testing.T) {
options := PolicySetUpdateOptions{
PolicyUpdatePatterns: []string{"*.rego", "policies/**"},
}

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

assert.Equal(t, options.PolicyUpdatePatterns, ps.PolicyUpdatePatterns)
})

t.Run("with invalid attributes", func(t *testing.T) {
ps, err := client.PolicySets.Update(ctx, psTest.ID, PolicySetUpdateOptions{
Name: String("nope/nope!"),
Expand Down
Loading