Skip to content

Commit 2373f71

Browse files
committed
linter
1 parent 48e0c2c commit 2373f71

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

internal/services/k8s/acl.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package k8s
22

33
import (
44
"context"
5+
56
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
67
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
78
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
@@ -53,13 +54,11 @@ func ResourceACL() *schema.Resource {
5354
Optional: true,
5455
Description: "The IP subnet to be allowed",
5556
ValidateFunc: validation.IsCIDR,
56-
//ExactlyOneOf: []string{"acl_rules.0.scaleway_ranges"},
5757
},
5858
"scaleway_ranges": {
5959
Type: schema.TypeBool,
6060
Optional: true,
6161
Description: "Allow access to cluster from all Scaleway ranges as defined in https://www.scaleway.com/en/docs/console/account/reference-content/scaleway-network-information/#ip-ranges-used-by-scaleway. Only one rule with this field set to true can be added",
62-
//ExactlyOneOf: []string{"acl_rules.0.ip"},
6362
},
6463
"description": {
6564
Type: schema.TypeString,
@@ -172,6 +171,7 @@ func ResourceACLUpdate(ctx context.Context, d *schema.ResourceData, m interface{
172171
ClusterID: clusterID,
173172
ACLs: acls,
174173
}
174+
175175
_, err = api.SetClusterACLRules(req, scw.WithContext(ctx))
176176
if err != nil {
177177
return diag.FromErr(err)
@@ -206,6 +206,7 @@ func ResourceACLDelete(ctx context.Context, d *schema.ResourceData, m interface{
206206
},
207207
},
208208
}
209+
209210
_, err = api.SetClusterACLRules(req, scw.WithContext(ctx))
210211
if err != nil {
211212
return diag.FromErr(err)
@@ -231,11 +232,14 @@ func expandACL(data []interface{}) ([]*k8s.ACLRuleRequest, error) {
231232
if err != nil {
232233
return nil, err
233234
}
235+
234236
expandedRule.IP = &ip
235237
}
236-
if scwRangesRaw, scwRangesSet := r["scaleway_ranges"]; scwRangesSet && scwRangesRaw.(bool) == true {
238+
239+
if scwRangesRaw, scwRangesSet := r["scaleway_ranges"]; scwRangesSet && scwRangesRaw.(bool) {
237240
expandedRule.ScalewayRanges = scw.BoolPtr(true)
238241
}
242+
239243
if descriptionRaw, descriptionSet := r["description"]; descriptionSet && descriptionRaw.(string) != "" {
240244
expandedRule.Description = descriptionRaw.(string)
241245
}
@@ -252,6 +256,7 @@ func flattenACL(rules []*k8s.ACLRule) interface{} {
252256
}
253257

254258
flattenedACLs := []map[string]interface{}(nil)
259+
255260
for _, rule := range rules {
256261
flattenedRule := map[string]interface{}{
257262
"id": rule.ID,
@@ -261,6 +266,7 @@ func flattenACL(rules []*k8s.ACLRule) interface{} {
261266
if rule.IP != nil {
262267
flattenedRule["ip"] = rule.IP.String()
263268
}
269+
264270
flattenedACLs = append(flattenedACLs, flattenedRule)
265271
}
266272

internal/services/k8s/acl_test.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ package k8s_test
22

33
import (
44
"fmt"
5+
"testing"
6+
57
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
68
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
79
k8sSDK "github.com/scaleway/scaleway-sdk-go/api/k8s/v1"
810
"github.com/scaleway/terraform-provider-scaleway/v2/internal/acctest"
911
"github.com/scaleway/terraform-provider-scaleway/v2/internal/services/k8s"
10-
"testing"
1112
)
1213

1314
func TestAccACL_Basic(t *testing.T) {
@@ -164,13 +165,13 @@ func testAccCheckK8SClusterAllIPsAllowed(tt *acctest.TestTools, n string) resour
164165
if err != nil {
165166
return err
166167
}
167-
if acls.TotalCount > 1 {
168+
169+
switch {
170+
case acls.TotalCount > 1:
168171
return fmt.Errorf("unexpected number of ACL rules: %d (expected: 1)", acls.TotalCount)
169-
}
170-
if acls.Rules[0].IP == nil {
171-
return fmt.Errorf("unexpected CL rule: %+v", acls.Rules[0])
172-
}
173-
if acls.Rules[0].IP.String() != "0.0.0.0/0" {
172+
case acls.Rules[0].IP == nil:
173+
return fmt.Errorf("unexpected ACL rule: %+v", acls.Rules[0])
174+
case acls.Rules[0].IP.String() != "0.0.0.0/0":
174175
return fmt.Errorf("unexpected IP in ACL rule: %q (expected \"0.0.0.0/0\")", acls.Rules[0].IP.String())
175176
}
176177

0 commit comments

Comments
 (0)