Skip to content

Commit

Permalink
fix(redis): change acl from list to set (#1366)
Browse files Browse the repository at this point in the history
  • Loading branch information
Codelax committed Jul 12, 2022
1 parent 27b2a0c commit 05b7d09
Show file tree
Hide file tree
Showing 4 changed files with 258 additions and 325 deletions.
2 changes: 1 addition & 1 deletion scaleway/helpers_redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func expandRedisPrivateNetwork(data []interface{}) ([]*redis.EndpointSpec, error
func expandRedisACLSpecs(i interface{}) ([]*redis.ACLRuleSpec, error) {
rules := []*redis.ACLRuleSpec(nil)

for _, aclRule := range i.([]interface{}) {
for _, aclRule := range i.(*schema.Set).List() {
rawRule := aclRule.(map[string]interface{})
rule := &redis.ACLRuleSpec{}
if ruleDescription, hasDescription := rawRule["description"]; hasDescription {
Expand Down
2 changes: 1 addition & 1 deletion scaleway/resource_redis_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func resourceScalewayRedisCluster() *schema.Resource {
ForceNew: true,
},
"acl": {
Type: schema.TypeList,
Type: schema.TypeSet,
Description: "List of acl rules.",
Optional: true,
Elem: &schema.Resource{
Expand Down
12 changes: 8 additions & 4 deletions scaleway/resource_redis_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,15 @@ func TestAccScalewayRedisCluster_ACL(t *testing.T) {
resource.TestCheckResourceAttr("scaleway_redis_cluster.main", "node_type", "MDB-BETA-M"),
resource.TestCheckResourceAttr("scaleway_redis_cluster.main", "user_name", "my_initial_user"),
resource.TestCheckResourceAttr("scaleway_redis_cluster.main", "password", "thiZ_is_v&ry_s3cret"),
resource.TestCheckResourceAttr("scaleway_redis_cluster.main", "acl.0.ip", "0.0.0.0/0"),
resource.TestCheckResourceAttr("scaleway_redis_cluster.main", "acl.0.description", "An acl description"),
resource.TestCheckTypeSetElemNestedAttrs("scaleway_redis_cluster.main", "acl.*", map[string]string{
"ip": "0.0.0.0/0",
"description": "An acl description",
}),
resource.TestCheckTypeSetElemNestedAttrs("scaleway_redis_cluster.main", "acl.*", map[string]string{
"ip": "192.168.10.0/24",
"description": "A second acl description",
}),
resource.TestCheckResourceAttrSet("scaleway_redis_cluster.main", "acl.0.id"),
resource.TestCheckResourceAttr("scaleway_redis_cluster.main", "acl.1.ip", "192.168.10.0/24"),
resource.TestCheckResourceAttr("scaleway_redis_cluster.main", "acl.1.description", "A second acl description"),
resource.TestCheckResourceAttrSet("scaleway_redis_cluster.main", "acl.1.id"),
),
},
Expand Down

0 comments on commit 05b7d09

Please sign in to comment.