From 32c3d86dce16e5d38f7bb6f39d5820d5b2ed4733 Mon Sep 17 00:00:00 2001 From: emlanctot Date: Tue, 7 May 2024 12:59:04 -0700 Subject: [PATCH] chore: ignore linter complaints for deprecated policy.Enforce --- internal/provider/resource_tfe_policy.go | 6 ++++-- internal/provider/resource_tfe_policy_test.go | 7 +++++++ internal/provider/resource_tfe_sentinel_policy.go | 2 ++ internal/provider/resource_tfe_sentinel_policy_test.go | 2 ++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/internal/provider/resource_tfe_policy.go b/internal/provider/resource_tfe_policy.go index ff0cd9c3f..cc9a8d575 100644 --- a/internal/provider/resource_tfe_policy.go +++ b/internal/provider/resource_tfe_policy.go @@ -194,7 +194,7 @@ func createOPAPolicyOptions(options *tfe.PolicyCreateOptions, d *schema.Resource enforceOpts.Mode = tfe.EnforcementMode(tfe.EnforcementLevel(v.(string))) } - options.Enforce = []*tfe.EnforcementOptions{enforceOpts} + options.Enforce = []*tfe.EnforcementOptions{enforceOpts} //nolint:staticcheck // this is still used by TFE version 202306-1 vQuery, ok := d.GetOk("query") if !ok { @@ -218,7 +218,7 @@ func createSentinelPolicyOptions(options *tfe.PolicyCreateOptions, d *schema.Res enforceOpts.Mode = tfe.EnforcementMode(tfe.EnforcementLevel(v.(string))) } - options.Enforce = []*tfe.EnforcementOptions{enforceOpts} + options.Enforce = []*tfe.EnforcementOptions{enforceOpts} //nolint:staticcheck // this is still used by TFE version 202306-1 return options } @@ -254,6 +254,7 @@ func resourceTFEPolicyRead(d *schema.ResourceData, meta interface{}) error { d.Set("description", policy.Description) d.Set("kind", policy.Kind) + //nolint:staticcheck // this is still used by TFE version 202306-1 if len(policy.Enforce) == 1 { d.Set("enforce_mode", string(policy.Enforce[0].Mode)) } @@ -287,6 +288,7 @@ func resourceTFEPolicyUpdate(d *schema.ResourceData, meta interface{}) error { } } if d.HasChange("enforce_mode") { + //nolint:staticcheck // this is still used by TFE version 202306-1 options.Enforce = []*tfe.EnforcementOptions{ { Path: tfe.String(path), diff --git a/internal/provider/resource_tfe_policy_test.go b/internal/provider/resource_tfe_policy_test.go index f0def6962..e5a7e5408 100644 --- a/internal/provider/resource_tfe_policy_test.go +++ b/internal/provider/resource_tfe_policy_test.go @@ -404,6 +404,7 @@ func testAccCheckTFEPolicyAttributes( return fmt.Errorf("Bad name: %s", policy.Name) } + //nolint:staticcheck // this is still used by TFE version 202306-1 if policy.Enforce[0].Mode != "hard-mandatory" { return fmt.Errorf("Bad enforce mode: %s", policy.Enforce[0].Mode) } @@ -419,6 +420,7 @@ func testAccCheckTFEOPAPolicyAttributes( return fmt.Errorf("Bad name: %s", policy.Name) } + //nolint:staticcheck // this is still used by TFE version 202306-1 if policy.Enforce[0].Mode != "mandatory" { return fmt.Errorf("Bad enforce mode: %s", policy.Enforce[0].Mode) } @@ -438,10 +440,12 @@ func testAccCheckTFEDefaultPolicyAttributes(policy *tfe.Policy) resource.TestChe } switch policy.Kind { + //nolint:staticcheck // this is still used by TFE version 202306-1 case tfe.Sentinel: if policy.Enforce[0].Mode != "soft-mandatory" { return fmt.Errorf("Bad enforce mode: %s", policy.Enforce[0].Mode) } + //nolint:staticcheck // this is still used by TFE version 202306-1 case tfe.OPA: if policy.Enforce[0].Mode != "advisory" { return fmt.Errorf("Bad enforce mode: %s", policy.Enforce[0].Mode) @@ -458,6 +462,7 @@ func testAccCheckTFEPolicyAttributesUpdated( return fmt.Errorf("Bad name: %s", policy.Name) } + //nolint:staticcheck // this is still used by TFE version 202306-1 if policy.Enforce[0].Mode != "soft-mandatory" { return fmt.Errorf("Bad enforce mode: %s", policy.Enforce[0].Mode) } @@ -473,6 +478,7 @@ func testAccCheckTFEOPAPolicyAttributesUpdatedQuery( return fmt.Errorf("Bad name: %s", policy.Name) } + //nolint:staticcheck // this is still used by TFE version 202306-1 if policy.Enforce[0].Mode != "mandatory" { return fmt.Errorf("Bad enforce mode: %s", policy.Enforce[0].Mode) } @@ -492,6 +498,7 @@ func testAccCheckTFEOPAPolicyAttributesUpdatedAll( return fmt.Errorf("Bad name: %s", policy.Name) } + //nolint:staticcheck // this is still used by TFE version 202306-1 if policy.Enforce[0].Mode != "advisory" { return fmt.Errorf("Bad enforce mode: %s", policy.Enforce[0].Mode) } diff --git a/internal/provider/resource_tfe_sentinel_policy.go b/internal/provider/resource_tfe_sentinel_policy.go index 644f78729..86bed8b61 100644 --- a/internal/provider/resource_tfe_sentinel_policy.go +++ b/internal/provider/resource_tfe_sentinel_policy.go @@ -136,6 +136,7 @@ func resourceTFESentinelPolicyRead(d *schema.ResourceData, meta interface{}) err d.Set("name", policy.Name) d.Set("description", policy.Description) + //nolint:staticcheck // this is still used by TFE version 202306-1 if len(policy.Enforce) == 1 { d.Set("enforce_mode", string(policy.Enforce[0].Mode)) } @@ -161,6 +162,7 @@ func resourceTFESentinelPolicyUpdate(d *schema.ResourceData, meta interface{}) e } if d.HasChange("enforce_mode") { + //nolint:staticcheck // this is still used by TFE version 202306-1 options.Enforce = []*tfe.EnforcementOptions{ { Path: tfe.String(d.Get("name").(string) + ".sentinel"), diff --git a/internal/provider/resource_tfe_sentinel_policy_test.go b/internal/provider/resource_tfe_sentinel_policy_test.go index 075233967..892307515 100644 --- a/internal/provider/resource_tfe_sentinel_policy_test.go +++ b/internal/provider/resource_tfe_sentinel_policy_test.go @@ -147,6 +147,7 @@ func testAccCheckTFESentinelPolicyAttributes( return fmt.Errorf("Bad name: %s", policy.Name) } + //nolint:staticcheck // this is still used by TFE version 202306-1 if policy.Enforce[0].Mode != "hard-mandatory" { return fmt.Errorf("Bad enforce mode: %s", policy.Enforce[0].Mode) } @@ -162,6 +163,7 @@ func testAccCheckTFESentinelPolicyAttributesUpdated( return fmt.Errorf("Bad name: %s", policy.Name) } + //nolint:staticcheck // this is still used by TFE version 202306-1 if policy.Enforce[0].Mode != "soft-mandatory" { return fmt.Errorf("Bad enforce mode: %s", policy.Enforce[0].Mode) }