From 966d2c24c8f5a2c21db915f40a58cf0d36de5ac3 Mon Sep 17 00:00:00 2001 From: mrinalirao Date: Wed, 16 Nov 2022 10:05:50 +1100 Subject: [PATCH] Skip Beta tests in CI and add CHANGELOG --- CHANGELOG.md | 1 + tfe/resource_tfe_policy.go | 6 ++++-- tfe/resource_tfe_policy_test.go | 6 ++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b74267e0f..2db9c12d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ 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: Add OPA support for policies ([#690](https://github.com/hashicorp/terraform-provider-tfe/pull/690)) ## v0.38.0 (October 24, 2022) diff --git a/tfe/resource_tfe_policy.go b/tfe/resource_tfe_policy.go index 1fe622015..58cbb44da 100644 --- a/tfe/resource_tfe_policy.go +++ b/tfe/resource_tfe_policy.go @@ -2,6 +2,7 @@ package tfe import ( "context" + "errors" "fmt" "log" "strings" @@ -167,7 +168,7 @@ func resourceTFEPolicyRead(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Read policy: %s", d.Id()) policy, err := tfeClient.Policies.Read(ctx, d.Id()) if err != nil { - if err == tfe.ErrResourceNotFound { + if errors.Is(err, tfe.ErrResourceNotFound) { log.Printf("[DEBUG] Policy %s does no longer exist", d.Id()) d.SetId("") return nil @@ -196,6 +197,7 @@ func resourceTFEPolicyRead(d *schema.ResourceData, meta interface{}) error { func resourceTFEPolicyUpdate(d *schema.ResourceData, meta interface{}) error { tfeClient := meta.(*tfe.Client) + // nolint:nestif if d.HasChange("description") || d.HasChange("enforce_mode") { // Create a new options struct. options := tfe.PolicyUpdateOptions{} @@ -246,7 +248,7 @@ func resourceTFEPolicyDelete(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Delete policy: %s", d.Id()) err := tfeClient.Policies.Delete(ctx, d.Id()) if err != nil { - if err == tfe.ErrResourceNotFound { + if errors.Is(err, tfe.ErrResourceNotFound) { return nil } return fmt.Errorf("Error deleting policy %s: %w", d.Id(), err) diff --git a/tfe/resource_tfe_policy_test.go b/tfe/resource_tfe_policy_test.go index 05c66d78d..eab7ecc49 100644 --- a/tfe/resource_tfe_policy_test.go +++ b/tfe/resource_tfe_policy_test.go @@ -10,6 +10,7 @@ import ( ) func TestAccTFEPolicy_basic(t *testing.T) { + skipUnlessBeta(t) tfeClient, err := getClientUsingEnv() if err != nil { t.Fatal(err) @@ -48,6 +49,7 @@ func TestAccTFEPolicy_basic(t *testing.T) { } func TestAccTFEPolicyOPA_basic(t *testing.T) { + skipUnlessBeta(t) tfeClient, err := getClientUsingEnv() if err != nil { t.Fatal(err) @@ -88,6 +90,7 @@ func TestAccTFEPolicyOPA_basic(t *testing.T) { } func TestAccTFEPolicy_update(t *testing.T) { + skipUnlessBeta(t) tfeClient, err := getClientUsingEnv() if err != nil { t.Fatal(err) @@ -143,6 +146,7 @@ func TestAccTFEPolicy_update(t *testing.T) { } func TestAccTFEPolicyOPA_update(t *testing.T) { + skipUnlessBeta(t) tfeClient, err := getClientUsingEnv() if err != nil { t.Fatal(err) @@ -202,6 +206,7 @@ func TestAccTFEPolicyOPA_update(t *testing.T) { } func TestAccTFEPolicy_import(t *testing.T) { + skipUnlessBeta(t) tfeClient, err := getClientUsingEnv() if err != nil { t.Fatal(err) @@ -245,6 +250,7 @@ func testAccCheckTFEPolicyExists( p, err := tfeClient.Policies.Read(ctx, rs.Primary.ID) if err != nil { + // nolint: wrapcheck return err }