From 48677826470f888f309e6a6537d0b5eddc27d767 Mon Sep 17 00:00:00 2001 From: Borys Pierov Date: Sat, 20 Apr 2019 01:18:57 -0400 Subject: [PATCH] Fix: Error on non-string values in `yaml_list_of_strings` - serialize them to flow-style YAML Closes #4 --- CHANGELOG.md | 6 +++++ yaml/data_source_yaml_list_of_strings.go | 2 +- yaml/data_source_yaml_list_of_strings_test.go | 26 ++++++++++++++++--- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 315f4bc..e2d2783 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## 2.0.2 - 2019-04-20 + +### Fixed + +- Error on non-string values in `yaml_list_of_strings` - serialize them to flow-style YAML + ## 2.0.1 - 2019-04-12 ### Fixed diff --git a/yaml/data_source_yaml_list_of_strings.go b/yaml/data_source_yaml_list_of_strings.go index e20f745..5bd5cf0 100644 --- a/yaml/data_source_yaml_list_of_strings.go +++ b/yaml/data_source_yaml_list_of_strings.go @@ -30,7 +30,7 @@ func dataSourceList() *schema.Resource { func readYamlList(d *schema.ResourceData, m interface{}) error { input := d.Get(FieldInput).(string) - var parsed []string + var parsed []interface{} err := yml.Unmarshal([]byte(input), &parsed) if err != nil { diff --git a/yaml/data_source_yaml_list_of_strings_test.go b/yaml/data_source_yaml_list_of_strings_test.go index 76cf63a..295a954 100644 --- a/yaml/data_source_yaml_list_of_strings_test.go +++ b/yaml/data_source_yaml_list_of_strings_test.go @@ -9,7 +9,7 @@ import ( "reflect" ) -const listInput = ` +const inputListOfStrings = ` output "result" { value="${data.yaml_list_of_strings.doc.output}" } data "yaml_list_of_strings" "doc" { @@ -20,17 +20,35 @@ EOF } ` +const inputListOfMaps = ` +output "result" { value="${data.yaml_list_of_strings.doc.output}" } + +data "yaml_list_of_strings" "doc" { + input = <