Skip to content

Commit b8bf385

Browse files
committed
chore: ignore linter complaints for deprecated policy.Enforce
(cherry picked from commit 32c3d86)
1 parent a015dfd commit b8bf385

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

internal/provider/resource_tfe_policy.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func createOPAPolicyOptions(options *tfe.PolicyCreateOptions, d *schema.Resource
194194
enforceOpts.Mode = tfe.EnforcementMode(tfe.EnforcementLevel(v.(string)))
195195
}
196196

197-
options.Enforce = []*tfe.EnforcementOptions{enforceOpts}
197+
options.Enforce = []*tfe.EnforcementOptions{enforceOpts} //nolint:staticcheck // this is still used by TFE versions older than 202306-1
198198

199199
vQuery, ok := d.GetOk("query")
200200
if !ok {
@@ -218,7 +218,7 @@ func createSentinelPolicyOptions(options *tfe.PolicyCreateOptions, d *schema.Res
218218
enforceOpts.Mode = tfe.EnforcementMode(tfe.EnforcementLevel(v.(string)))
219219
}
220220

221-
options.Enforce = []*tfe.EnforcementOptions{enforceOpts}
221+
options.Enforce = []*tfe.EnforcementOptions{enforceOpts} //nolint:staticcheck // this is still used by TFE versions older than 202306-1
222222
return options
223223
}
224224

@@ -254,6 +254,7 @@ func resourceTFEPolicyRead(d *schema.ResourceData, meta interface{}) error {
254254
d.Set("description", policy.Description)
255255
d.Set("kind", policy.Kind)
256256

257+
//nolint:staticcheck // this is still used by TFE versions older than 202306-1
257258
if len(policy.Enforce) == 1 {
258259
d.Set("enforce_mode", string(policy.Enforce[0].Mode))
259260
}
@@ -287,6 +288,7 @@ func resourceTFEPolicyUpdate(d *schema.ResourceData, meta interface{}) error {
287288
}
288289
}
289290
if d.HasChange("enforce_mode") {
291+
//nolint:staticcheck // this is still used by TFE versions older than 202306-1
290292
options.Enforce = []*tfe.EnforcementOptions{
291293
{
292294
Path: tfe.String(path),

internal/provider/resource_tfe_policy_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@ func testAccCheckTFEPolicyAttributes(
404404
return fmt.Errorf("Bad name: %s", policy.Name)
405405
}
406406

407+
//nolint:staticcheck // this is still used by TFE versions older than 202306-1
407408
if policy.Enforce[0].Mode != "hard-mandatory" {
408409
return fmt.Errorf("Bad enforce mode: %s", policy.Enforce[0].Mode)
409410
}
@@ -419,6 +420,7 @@ func testAccCheckTFEOPAPolicyAttributes(
419420
return fmt.Errorf("Bad name: %s", policy.Name)
420421
}
421422

423+
//nolint:staticcheck // this is still used by TFE versions older than 202306-1
422424
if policy.Enforce[0].Mode != "mandatory" {
423425
return fmt.Errorf("Bad enforce mode: %s", policy.Enforce[0].Mode)
424426
}
@@ -438,10 +440,12 @@ func testAccCheckTFEDefaultPolicyAttributes(policy *tfe.Policy) resource.TestChe
438440
}
439441

440442
switch policy.Kind {
443+
//nolint:staticcheck // this is still used by TFE versions older than 202306-1
441444
case tfe.Sentinel:
442445
if policy.Enforce[0].Mode != "soft-mandatory" {
443446
return fmt.Errorf("Bad enforce mode: %s", policy.Enforce[0].Mode)
444447
}
448+
//nolint:staticcheck // this is still used by TFE versions older than 202306-1
445449
case tfe.OPA:
446450
if policy.Enforce[0].Mode != "advisory" {
447451
return fmt.Errorf("Bad enforce mode: %s", policy.Enforce[0].Mode)
@@ -458,6 +462,7 @@ func testAccCheckTFEPolicyAttributesUpdated(
458462
return fmt.Errorf("Bad name: %s", policy.Name)
459463
}
460464

465+
//nolint:staticcheck // this is still used by TFE versions older than 202306-1
461466
if policy.Enforce[0].Mode != "soft-mandatory" {
462467
return fmt.Errorf("Bad enforce mode: %s", policy.Enforce[0].Mode)
463468
}
@@ -473,6 +478,7 @@ func testAccCheckTFEOPAPolicyAttributesUpdatedQuery(
473478
return fmt.Errorf("Bad name: %s", policy.Name)
474479
}
475480

481+
//nolint:staticcheck // this is still used by TFE versions older than 202306-1
476482
if policy.Enforce[0].Mode != "mandatory" {
477483
return fmt.Errorf("Bad enforce mode: %s", policy.Enforce[0].Mode)
478484
}
@@ -492,6 +498,7 @@ func testAccCheckTFEOPAPolicyAttributesUpdatedAll(
492498
return fmt.Errorf("Bad name: %s", policy.Name)
493499
}
494500

501+
//nolint:staticcheck // this is still used by TFE versions older than 202306-1
495502
if policy.Enforce[0].Mode != "advisory" {
496503
return fmt.Errorf("Bad enforce mode: %s", policy.Enforce[0].Mode)
497504
}

internal/provider/resource_tfe_sentinel_policy.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ func resourceTFESentinelPolicyRead(d *schema.ResourceData, meta interface{}) err
136136
d.Set("name", policy.Name)
137137
d.Set("description", policy.Description)
138138

139+
//nolint:staticcheck // this is still used by TFE versions older than 202306-1
139140
if len(policy.Enforce) == 1 {
140141
d.Set("enforce_mode", string(policy.Enforce[0].Mode))
141142
}
@@ -161,6 +162,7 @@ func resourceTFESentinelPolicyUpdate(d *schema.ResourceData, meta interface{}) e
161162
}
162163

163164
if d.HasChange("enforce_mode") {
165+
//nolint:staticcheck // this is still used by TFE versions older than 202306-1
164166
options.Enforce = []*tfe.EnforcementOptions{
165167
{
166168
Path: tfe.String(d.Get("name").(string) + ".sentinel"),

internal/provider/resource_tfe_sentinel_policy_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ func testAccCheckTFESentinelPolicyAttributes(
147147
return fmt.Errorf("Bad name: %s", policy.Name)
148148
}
149149

150+
//nolint:staticcheck // this is still used by TFE versions older than 202306-1
150151
if policy.Enforce[0].Mode != "hard-mandatory" {
151152
return fmt.Errorf("Bad enforce mode: %s", policy.Enforce[0].Mode)
152153
}
@@ -162,6 +163,7 @@ func testAccCheckTFESentinelPolicyAttributesUpdated(
162163
return fmt.Errorf("Bad name: %s", policy.Name)
163164
}
164165

166+
//nolint:staticcheck // this is still used by TFE versions older than 202306-1
165167
if policy.Enforce[0].Mode != "soft-mandatory" {
166168
return fmt.Errorf("Bad enforce mode: %s", policy.Enforce[0].Mode)
167169
}

0 commit comments

Comments
 (0)