Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InterfaceToVariable: Maintain backward compatibility #63

Merged
merged 1 commit into from
Feb 12, 2019

Conversation

radeksimko
Copy link
Member

@radeksimko radeksimko commented Feb 11, 2019

This was discovered when upgrading mitchellh/mapstructure to its new version which contains mitchellh/mapstructure#98 which in turn caused some tests in hashicorp/terraform to fail:

--- FAIL: TestInterpolateFuncMap (0.00s)
    --- FAIL: TestInterpolateFuncMap/${map("hello",_list("world"),_"what's",_list("up?"))} (0.00s)
        interpolate_funcs_test.go:2487: wrong result
            given: ${map("hello", list("world"), "what's", list("up?"))}
            got:   map[string]interface {}{"hello":map[string]interface {}{"Value":"world", "Type":"8"}, "what's":map[string]interface {}{"Value":"up?", "Type":"8"}}
            want:  map[string]interface {}{"hello":[]interface {}{"world"}, "what's":[]interface {}{"up?"}}
--- FAIL: TestInterpolateFuncMerge (0.00s)
    --- FAIL: TestInterpolateFuncMerge/${merge(map("a",_list("b")),_map("c",_list("d",_"e")))} (0.00s)
        interpolate_funcs_test.go:2487: wrong result
            given: ${merge(map("a", list("b")), map("c", list("d", "e")))}
            got:   map[string]interface {}{"a":map[string]interface {}{"Value":"b", "Type":"8"}, "c":map[string]interface {}{"Value":"e", "Type":"8"}}
            want:  map[string]interface {}{"a":[]interface {}{"b"}, "c":[]interface {}{"d", "e"}}
    --- FAIL: TestInterpolateFuncMerge/${merge(map("a",_var.maps[0]),_map("b",_list("c",_"d")))} (0.00s)
        interpolate_funcs_test.go:2487: wrong result
            given: ${merge(map("a", var.maps[0]), map("b", list("c", "d")))}
            got:   map[string]interface {}{"a":map[string]interface {}{"key1":"a", "key2":"b"}, "b":map[string]interface {}{"Value":"d", "Type":"8"}}
            want:  map[string]interface {}{"a":map[string]interface {}{"key2":"b", "key1":"a"}, "b":[]interface {}{"c", "d"}}
--- FAIL: TestInterpolateFuncJSONEncode (0.00s)
    --- FAIL: TestInterpolateFuncJSONEncode/${jsonencode(nestedlist)} (0.00s)
        interpolate_funcs_test.go:2487: wrong result
            given: ${jsonencode(nestedlist)}
            got:   "{\"Type\":\"64\",\"Value\":{\"Type\":\"8\",\"Value\":\"foo\"}}"
            want:  "[[\"foo\"]]"
FAIL
FAIL	github.com/hashicorp/terraform/config	0.296s

with this patch the mentioned tests pass:

$ go test -mod=vendor ./config
ok  	github.com/hashicorp/terraform/config	0.826s

@radeksimko radeksimko changed the title InterfaceToVariable: Error on conversion of existing variables [WIP] InterfaceToVariable: Error on conversion of existing variables Feb 11, 2019
@radeksimko radeksimko changed the title [WIP] InterfaceToVariable: Error on conversion of existing variables [WIP] InterfaceToVariable: Maintain backward compatibility Feb 11, 2019
@radeksimko radeksimko changed the title [WIP] InterfaceToVariable: Maintain backward compatibility InterfaceToVariable: Maintain backward compatibility Feb 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants