diff --git a/CHANGELOG.md b/CHANGELOG.md index 60c858957..7a6877c19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/policy_set.go b/policy_set.go index c2a4ccbad..f199d9ca5 100644 --- a/policy_set.go +++ b/policy_set.go @@ -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"` @@ -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. @@ -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. diff --git a/policy_set_integration_test.go b/policy_set_integration_test.go index f0e17ffd4..010fc9fad 100644 --- a/policy_set_integration_test.go +++ b/policy_set_integration_test.go @@ -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)), @@ -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!"),