Skip to content

Commit

Permalink
Converting the existing fields to proper data types
Browse files Browse the repository at this point in the history
  • Loading branch information
tombuildsstuff committed Jun 28, 2017
1 parent 9c41aec commit 61aed53
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
37 changes: 19 additions & 18 deletions azurerm/resource_arm_redis_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,19 @@ func resourceArmRedisCache() *schema.Resource {
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"maxclients": {
Type: schema.TypeString,
Type: schema.TypeInt,
Optional: true,
Computed: true,
},

"maxmemory_delta": {
Type: schema.TypeString,
Type: schema.TypeInt,
Optional: true,
Computed: true,
},

"maxmemory_reserved": {
Type: schema.TypeString,
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
Expand Down Expand Up @@ -395,19 +395,22 @@ func expandRedisConfiguration(d *schema.ResourceData) *map[string]*string {
for _, v := range configuration {
config := v.(map[string]interface{})

maxClients := config["maxclients"].(string)
if maxClients != "" {
output["maxclients"] = azure.String(maxClients)
if v := config["maxclients"]; v != nil {
clientsI := v.(int)
clients := strconv.Itoa(clientsI)
output["maxclients"] = azure.String(clients)
}

maxMemoryDelta := config["maxmemory_delta"].(string)
if maxMemoryDelta != "" {
output["maxmemory-delta"] = azure.String(maxMemoryDelta)
if v := config["maxmemory_delta"]; v != nil {
memI := v.(int)
mem := strconv.Itoa(memI)
output["maxmemory-delta"] = azure.String(mem)
}

maxMemoryReserved := config["maxmemory_reserved"].(string)
if maxMemoryReserved != "" {
output["maxmemory-reserved"] = azure.String(maxMemoryReserved)
if v := config["maxmemory_reserved"]; v != nil {
memI := v.(int)
mem := strconv.Itoa(memI)
output["maxmemory-reserved"] = azure.String(mem)
}

maxMemoryPolicy := config["maxmemory_policy"].(string)
Expand All @@ -421,15 +424,13 @@ func expandRedisConfiguration(d *schema.ResourceData) *map[string]*string {
output["rdb-backup-enabled"] = azure.String(enabled)
}

if v := config["rdb_backup_frequency"]; v != nil {
frequencyI := v.(int)
frequency := strconv.Itoa(frequencyI)
if v := config["rdb_backup_frequency"].(int); v > 0 {
frequency := strconv.Itoa(v)
output["rdb-backup-frequency"] = azure.String(frequency)
}

if v := config["rdb_backup_max_snapshot_count"]; v != nil {
countI := v.(int)
count := strconv.Itoa(countI)
if v := config["rdb_backup_max_snapshot_count"].(int); v > 0 {
count := strconv.Itoa(v)
output["rdb-backup-max-snapshot-count"] = azure.String(count)
}

Expand Down
10 changes: 5 additions & 5 deletions azurerm/resource_arm_redis_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,9 @@ resource "azurerm_redis_cache" "test" {
sku_name = "Premium"
enable_non_ssl_port = false
redis_configuration {
maxclients = "256",
maxmemory_reserved = "2",
maxmemory_delta = "2"
maxclients = 256,
maxmemory_reserved = 2,
maxmemory_delta = 2
maxmemory_policy = "allkeys-lru"
}
}
Expand All @@ -415,8 +415,8 @@ resource "azurerm_redis_cache" "test" {
shard_count = 3
redis_configuration {
maxclients = "256",
maxmemory_reserved = "2",
maxmemory_delta = "2"
maxmemory_reserved = 2,
maxmemory_delta = 2
maxmemory_policy = "allkeys-lru"
}
}
Expand Down

0 comments on commit 61aed53

Please sign in to comment.