Commit Graph

8 Commits

Author SHA1 Message Date
James Bardin 6fee1f24ab don't add duplicate unknowns to a set
The flatmap shim was lazily adding duplicate items and letting cty.Set
clear them out, but if those duplicates contains unknown values they
can't be checked for equality and will end up remaining in the set.
2018-11-13 18:41:53 -05:00
James Bardin 9d8ca4515e unknown collections in a flatmap
Unknown collections in a flatmap also need to be converted to unknown
values.
2018-10-16 19:14:11 -07:00
Martin Atkins 8cc8bacce3 config/hcl2shim: Treat DynamicVal like any other unknown value in flatmap 2018-10-16 19:14:11 -07:00
James Bardin 05e85885f9 handle Null collections in flatmaps
When creating a flatmap from a cty.Value, there may be Null collections
which don't need to be added to the flatmap at all. Skip over these to
avoid panicking in ElementIterator with a Null value.
2018-10-16 18:53:51 -07:00
James Bardin c28ce02f2a 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.
2018-10-16 18:50:29 -07:00
James Bardin ac8ee20233 return a NullVal when presented with a nil flatmap
This allows us to decode the cty.Value back to a nil map, rather than
trying to create a map with nil values.
2018-10-16 18:50:29 -07:00
Martin Atkins 299fe25a04 hcl2shim: Handle unknown values when shimming to/from flatmap
Previously unknown values were round-tripping through flatmap and coming
out as known strings containing the UnknownVariableValue. (The classic bug
that, ironically, was one of the big reasons to write cty!)

Now we properly handle unknown values in both directions: going in to
flatmap we write UnknownVariableValue at the appropriate key (as the count
for sequences or maps) and then coming out of flatmap we turn
UnknownVariableValue back into a cty unknown value of the requested type.
2018-10-16 18:48:28 -07:00
Martin Atkins ccc1b6990f config/hcl2shim: shims from flatmap to cty and vice-versa
These particular shims will have a pretty limited lifetime in mainline
Terraform code (primarily to stub out the new expression evaluator against
the old state structs until the new format is implemented) but will live
on for some time in state migration and provider plugin compatibility
shims.
2018-10-16 18:46:46 -07:00