From 6c01d2202193333d7ad51f3bf072a66db0f2f358 Mon Sep 17 00:00:00 2001 From: mrinalirao Date: Wed, 16 Nov 2022 11:28:50 +1100 Subject: [PATCH] add CHANGELOG.md and fix broken tests --- CHANGELOG.md | 2 ++ tfe/data_source_policy_set.go | 1 - tfe/data_source_policy_set_test.go | 2 ++ tfe/resource_tfe_policy_set.go | 6 +++++- tfe/resource_tfe_policy_set_test.go | 15 +++++++++++++++ 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b74267e0f..651dbdef8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ FEATURES: * r/tfe_organization: Add `allow_force_delete_workspaces` attribute to set whether admins are permitted to delete workspaces with resource under management. ([#661](https://github.com/hashicorp/terraform-provider-tfe/pull/661)) +* r/tfe_policy_set: Add OPA support for policy sets. ([#691](https://github.com/hashicorp/terraform-provider-tfe/pull/691)) +* d/tfe_policy_set: Add optional `kind` and `overridable` fields for OPA policy sets ([#691](https://github.com/hashicorp/terraform-provider-tfe/pull/691)) ## v0.38.0 (October 24, 2022) diff --git a/tfe/data_source_policy_set.go b/tfe/data_source_policy_set.go index 1e2810cd6..db73fc344 100644 --- a/tfe/data_source_policy_set.go +++ b/tfe/data_source_policy_set.go @@ -36,7 +36,6 @@ func dataSourceTFEPolicySet() *schema.Resource { "kind": { Type: schema.TypeString, Optional: true, - Default: string(tfe.Sentinel), }, "overridable": { diff --git a/tfe/data_source_policy_set_test.go b/tfe/data_source_policy_set_test.go index b0277a573..760cd9b65 100644 --- a/tfe/data_source_policy_set_test.go +++ b/tfe/data_source_policy_set_test.go @@ -133,6 +133,8 @@ func TestAccTFEPolicySetDataSource_vcs(t *testing.T) { "data.tfe_policy_set.bar", "description", "Policy Set"), resource.TestCheckResourceAttr( "data.tfe_policy_set.bar", "global", "false"), + resource.TestCheckResourceAttr( + "data.tfe_policy_set.bar", "kind", "sentinel"), resource.TestCheckResourceAttr( "data.tfe_policy_set.bar", "organization", org.Name), resource.TestCheckResourceAttr( diff --git a/tfe/resource_tfe_policy_set.go b/tfe/resource_tfe_policy_set.go index 428fa4b71..82c6929b3 100644 --- a/tfe/resource_tfe_policy_set.go +++ b/tfe/resource_tfe_policy_set.go @@ -217,7 +217,6 @@ func resourceTFEPolicySetRead(d *schema.ResourceData, meta interface{}) error { // Update the config. d.Set("name", policySet.Name) d.Set("description", policySet.Description) - d.Set("kind", policySet.Kind) d.Set("global", policySet.Global) d.Set("policies_path", policySet.PoliciesPath) @@ -225,6 +224,11 @@ func resourceTFEPolicySetRead(d *schema.ResourceData, meta interface{}) error { d.Set("organization", policySet.Organization.Name) } + // Note: Old API endpoints return an empty string, so use the default in the schema + if policySet.Kind != "" { + d.Set("kind", policySet.Kind) + } + if policySet.Overridable != nil { d.Set("overridable", policySet.Overridable) } diff --git a/tfe/resource_tfe_policy_set_test.go b/tfe/resource_tfe_policy_set_test.go index 6da992ed9..fe8169462 100644 --- a/tfe/resource_tfe_policy_set_test.go +++ b/tfe/resource_tfe_policy_set_test.go @@ -125,6 +125,8 @@ func TestAccTFEPolicySet_update(t *testing.T) { "tfe_policy_set.foobar", "name", "terraform-populated"), resource.TestCheckResourceAttr( "tfe_policy_set.foobar", "global", "false"), + resource.TestCheckResourceAttr( + "tfe_policy_set.foobar", "kind", "sentinel"), resource.TestCheckResourceAttr( "tfe_policy_set.foobar", "policy_ids.#", "1"), resource.TestCheckResourceAttr( @@ -227,6 +229,8 @@ func TestAccTFEPolicySet_updatePopulated(t *testing.T) { "tfe_policy_set.foobar", "name", "terraform-populated-updated"), resource.TestCheckResourceAttr( "tfe_policy_set.foobar", "global", "false"), + resource.TestCheckResourceAttr( + "tfe_policy_set.foobar", "kind", "sentinel"), resource.TestCheckResourceAttr( "tfe_policy_set.foobar", "policy_ids.#", "1"), resource.TestCheckResourceAttr( @@ -278,6 +282,8 @@ func TestAccTFEPolicySet_updateToGlobal(t *testing.T) { "tfe_policy_set.foobar", "name", "terraform-global"), resource.TestCheckResourceAttr( "tfe_policy_set.foobar", "global", "true"), + resource.TestCheckResourceAttr( + "tfe_policy_set.foobar", "kind", "sentinel"), resource.TestCheckResourceAttr( "tfe_policy_set.foobar", "policy_ids.#", "1"), ), @@ -376,6 +382,8 @@ func TestAccTFEPolicySet_vcs(t *testing.T) { "tfe_policy_set.foobar", "description", "Policy Set"), resource.TestCheckResourceAttr( "tfe_policy_set.foobar", "global", "false"), + resource.TestCheckResourceAttr( + "tfe_policy_set.foobar", "kind", "sentinel"), resource.TestCheckResourceAttr( "tfe_policy_set.foobar", "vcs_repo.0.identifier", GITHUB_POLICY_SET_IDENTIFIER), resource.TestCheckResourceAttr( @@ -431,6 +439,8 @@ func TestAccTFEPolicySet_updateVCSBranch(t *testing.T) { "tfe_policy_set.foobar", "description", "Policy Set"), resource.TestCheckResourceAttr( "tfe_policy_set.foobar", "global", "false"), + resource.TestCheckResourceAttr( + "tfe_policy_set.foobar", "kind", "sentinel"), resource.TestCheckResourceAttr( "tfe_policy_set.foobar", "vcs_repo.0.identifier", GITHUB_POLICY_SET_IDENTIFIER), resource.TestCheckResourceAttr( @@ -453,6 +463,8 @@ func TestAccTFEPolicySet_updateVCSBranch(t *testing.T) { "tfe_policy_set.foobar", "description", "Policy Set"), resource.TestCheckResourceAttr( "tfe_policy_set.foobar", "global", "false"), + resource.TestCheckResourceAttr( + "tfe_policy_set.foobar", "kind", "sentinel"), resource.TestCheckResourceAttr( "tfe_policy_set.foobar", "vcs_repo.0.identifier", GITHUB_POLICY_SET_IDENTIFIER), resource.TestCheckResourceAttr( @@ -666,6 +678,9 @@ func TestAccTFEPolicySetImport(t *testing.T) { ResourceName: "tfe_policy_set.foobar", ImportState: true, ImportStateVerify: true, + // Note: We ignore the optional fields below, since the old API endpoints send empty values + // and the results may vary depending on the API version + ImportStateVerifyIgnore: []string{"kind", "overridable"}, }, }, })