Skip to content

Commit

Permalink
fix: Use helpers to process data for TypeMap
Browse files Browse the repository at this point in the history
  • Loading branch information
vaerh committed May 11, 2023
1 parent aedc90e commit 280c994
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions routeros/mikrotik_serialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,8 @@ func TerraformResourceDataToMikrotik(s map[string]*schema.Schema, d *schema.Reso
}
}

s := v.(string)
// Conversion of boolean values.
if s == "true" {
s = "yes"
} else if s == "false" {
s = "no"
}
s := BoolToMikrotikJSONStr(v.(string))

item[k] = s
}
Expand Down Expand Up @@ -336,11 +331,8 @@ func MikrotikResourceDataToTerraform(item MikrotikItem, s map[string]*schema.Sch
}

case schema.TypeMap:
if mikrotikValue == "yes" {
mikrotikValue = "true"
} else if mikrotikValue == "no" {
mikrotikValue = "false"
}
// "yes" -> "true"; "no" -> "false"
mikrotikValue = BoolFromMikrotikJSONStr(mikrotikValue)

if _, ok := maps[terraformSnakeName]; !ok {
// Create a new map when processing the first incoming field.
Expand Down

0 comments on commit 280c994

Please sign in to comment.