While developing a provider I’ve come across situations where the defined type of a schema item is not being honored.
Introduction & Explanation
"enabled": {
Type: schema.TypeBool,
Default: true,
Optional: true,
},
"level": {
Type: schema.TypeInt,
Optional: true,
Default: 1,
Description: "The level of compression used for gzip",
},
delivery = {
compression = {
enabled = true
level = 2
}
}
mapContainingCompression := d.Get("delivery").(map[string]interface{})["compression"].(map[string]interface{})
test := mapContainingCompression["enabled"].(bool)
test2 := mapContainingCompression["level"].(int)
panic: interface conversion: interface {} is string, not bool
&
panic: interface conversion: interface {} is string, not int
This same process is working fine with other schema fields, however. Dumping the data via a log shows they are what I would expect
map[enabled:true level:2]
Question
What can be causing this? Why would they not be coming through properly