Skip to content

Commit 05b7d09

Browse files
authored
fix(redis): change acl from list to set (#1366)
1 parent 27b2a0c commit 05b7d09

4 files changed

+258
-325
lines changed

scaleway/helpers_redis.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func expandRedisPrivateNetwork(data []interface{}) ([]*redis.EndpointSpec, error
8585
func expandRedisACLSpecs(i interface{}) ([]*redis.ACLRuleSpec, error) {
8686
rules := []*redis.ACLRuleSpec(nil)
8787

88-
for _, aclRule := range i.([]interface{}) {
88+
for _, aclRule := range i.(*schema.Set).List() {
8989
rawRule := aclRule.(map[string]interface{})
9090
rule := &redis.ACLRuleSpec{}
9191
if ruleDescription, hasDescription := rawRule["description"]; hasDescription {

scaleway/resource_redis_cluster.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func resourceScalewayRedisCluster() *schema.Resource {
7676
ForceNew: true,
7777
},
7878
"acl": {
79-
Type: schema.TypeList,
79+
Type: schema.TypeSet,
8080
Description: "List of acl rules.",
8181
Optional: true,
8282
Elem: &schema.Resource{

scaleway/resource_redis_cluster_test.go

+8-4
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,15 @@ func TestAccScalewayRedisCluster_ACL(t *testing.T) {
204204
resource.TestCheckResourceAttr("scaleway_redis_cluster.main", "node_type", "MDB-BETA-M"),
205205
resource.TestCheckResourceAttr("scaleway_redis_cluster.main", "user_name", "my_initial_user"),
206206
resource.TestCheckResourceAttr("scaleway_redis_cluster.main", "password", "thiZ_is_v&ry_s3cret"),
207-
resource.TestCheckResourceAttr("scaleway_redis_cluster.main", "acl.0.ip", "0.0.0.0/0"),
208-
resource.TestCheckResourceAttr("scaleway_redis_cluster.main", "acl.0.description", "An acl description"),
207+
resource.TestCheckTypeSetElemNestedAttrs("scaleway_redis_cluster.main", "acl.*", map[string]string{
208+
"ip": "0.0.0.0/0",
209+
"description": "An acl description",
210+
}),
211+
resource.TestCheckTypeSetElemNestedAttrs("scaleway_redis_cluster.main", "acl.*", map[string]string{
212+
"ip": "192.168.10.0/24",
213+
"description": "A second acl description",
214+
}),
209215
resource.TestCheckResourceAttrSet("scaleway_redis_cluster.main", "acl.0.id"),
210-
resource.TestCheckResourceAttr("scaleway_redis_cluster.main", "acl.1.ip", "192.168.10.0/24"),
211-
resource.TestCheckResourceAttr("scaleway_redis_cluster.main", "acl.1.description", "A second acl description"),
212216
resource.TestCheckResourceAttrSet("scaleway_redis_cluster.main", "acl.1.id"),
213217
),
214218
},

0 commit comments

Comments
 (0)