flatmap: never auto-convert ints

This commit is contained in:
Mitchell Hashimoto 2014-07-24 11:40:46 -07:00
parent e2aeacc8d2
commit 308b88a8d8
2 changed files with 4 additions and 6 deletions

View File

@ -11,9 +11,7 @@ import (
func Expand(m map[string]string, key string) interface{} { func Expand(m map[string]string, key string) interface{} {
// If the key is exactly a key in the map, just return it // If the key is exactly a key in the map, just return it
if v, ok := m[key]; ok { if v, ok := m[key]; ok {
if num, err := strconv.ParseInt(v, 0, 0); err == nil { if v == "true" {
return int(num)
} else if v == "true" {
return true return true
} else if v == "false" { } else if v == "false" {
return false return false

View File

@ -44,7 +44,7 @@ func TestExpand(t *testing.T) {
Output: []interface{}{ Output: []interface{}{
map[string]interface{}{ map[string]interface{}{
"name": "bar", "name": "bar",
"port": 3000, "port": "3000",
"enabled": true, "enabled": true,
}, },
}, },
@ -63,8 +63,8 @@ func TestExpand(t *testing.T) {
map[string]interface{}{ map[string]interface{}{
"name": "bar", "name": "bar",
"ports": []interface{}{ "ports": []interface{}{
1, "1",
2, "2",
}, },
}, },
}, },