diff --git a/pkg/orderedmap/convert.go b/pkg/orderedmap/convert.go index c29db025..61ea5d1f 100644 --- a/pkg/orderedmap/convert.go +++ b/pkg/orderedmap/convert.go @@ -75,6 +75,15 @@ func (c Conversion) fromUnorderedMaps(object interface{}) interface{} { } return typedObj + // some sources (e.g. toml library) yield specific type of slices. + // slices in Go are not covariant, so each flavor of slice must have its own case, here. + // process these exactly the same way we do for generic slices (prior case) + case []map[string]interface{}: + resultArray := make([]interface{}, len(typedObj)) + for i, item := range typedObj { + resultArray[i] = c.fromUnorderedMaps(item) + } + return resultArray default: return typedObj } diff --git a/pkg/yamltemplate/filetests/ytt-library/toml.tpltest b/pkg/yamltemplate/filetests/ytt-library/toml.tpltest index 38039a14..24b7a6f4 100644 --- a/pkg/yamltemplate/filetests/ytt-library/toml.tpltest +++ b/pkg/yamltemplate/filetests/ytt-library/toml.tpltest @@ -6,6 +6,14 @@ fragment: - piece2 #@ end +#@ arrayOfTables = ''' +#@ [[stuff]] +#@ a = 1 +#@ +#@ [[stuff]] +#@ b = 2 +#@ ''' + encode: test1: #@ toml.encode({}) test2: #@ toml.encode({"a": [1,2,3,456], "b": "str"}) @@ -17,6 +25,7 @@ encode: decode: test1: #@ toml.decode("") test2: #@ toml.decode('a = [ 1, 2, 3, 456 ]\nb = "str"') + test3: #@ toml.decode(arrayOfTables) +++ @@ -55,3 +64,7 @@ decode: - 3 - 456 b: str + test3: + stuff: + - a: 1 + - b: 2