return a nil flatmap when presented with a NullVal
A nil flatmap will be encoded as a NullVal of the correct type. When Converting a NullVal back to a flatmap, return nil immediately rather than attempting to build the values.
This commit is contained in:
parent
ac8ee20233
commit
c28ce02f2a
|
@ -21,6 +21,10 @@ import (
|
||||||
// so the given value must not have any maps of complex types or the result
|
// so the given value must not have any maps of complex types or the result
|
||||||
// is undefined.
|
// is undefined.
|
||||||
func FlatmapValueFromHCL2(v cty.Value) map[string]string {
|
func FlatmapValueFromHCL2(v cty.Value) map[string]string {
|
||||||
|
if v.IsNull() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
if !v.Type().IsObjectType() {
|
if !v.Type().IsObjectType() {
|
||||||
panic(fmt.Sprintf("HCL2ValueFromFlatmap called on %#v", v.Type()))
|
panic(fmt.Sprintf("HCL2ValueFromFlatmap called on %#v", v.Type()))
|
||||||
}
|
}
|
||||||
|
|
|
@ -228,6 +228,14 @@ func TestFlatmapValueFromHCL2(t *testing.T) {
|
||||||
"foo.0.bap.%": UnknownVariableValue,
|
"foo.0.bap.%": UnknownVariableValue,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
cty.NullVal(cty.Object(map[string]cty.Type{
|
||||||
|
"foo": cty.Set(cty.Object(map[string]cty.Type{
|
||||||
|
"bar": cty.String,
|
||||||
|
})),
|
||||||
|
})),
|
||||||
|
nil,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
|
|
Loading…
Reference in New Issue