2018-12-01 03:23:09 +01:00
|
|
|
locals {
|
|
|
|
list = ["a", "b", "c"]
|
|
|
|
list_concat = concat(["a", "b"], ["c"])
|
|
|
|
list_empty = []
|
|
|
|
|
|
|
|
map = {
|
|
|
|
"a" = "b"
|
|
|
|
"c" = "d"
|
|
|
|
}
|
|
|
|
map_merge = merge(
|
|
|
|
{
|
|
|
|
"a" = "b"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"c" = "d"
|
|
|
|
},
|
|
|
|
)
|
|
|
|
map_empty = {}
|
|
|
|
map_invalid = map("a", "b", "c")
|
|
|
|
|
|
|
|
list_of_map = [
|
|
|
|
{
|
|
|
|
"a" = "b"
|
|
|
|
},
|
|
|
|
]
|
|
|
|
map_of_list = {
|
|
|
|
"a" = ["b"]
|
|
|
|
}
|
2018-12-01 03:29:56 +01:00
|
|
|
|
|
|
|
lookup_literal = {
|
|
|
|
"a" = "b"
|
|
|
|
}["a"]
|
|
|
|
lookup_ref = local.map["a"]
|
configs/configupgrade: Fix up internal HIL conversion functions
HIL implemented its type conversions by rewriting its AST to include calls
to some undocumented builtin functions. Unfortunately those functions were
still explicitly callable if you could figure out the name for them, and
so they may have been used in the wild.
In particular, __builtin_StringToFloat was used as part of a workaround
for a HIL design flaw where it would prefer to convert strings to integers
rather than floats when performing arithmetic operations. This issue was,
indeed, the main reason for unifying int ant float into a single number
type in HCL. Since we published that as a suggested workaround, the
upgrade tool ought to fix it up.
The other cases have never been documented as a workaround, so they are
less likely to appear in the wild, but we might as well fix them up anyway
since we already have the conversion functions required to get the same
result in the new language.
To be safe/conservative, most of these convert to _two_ function calls
rather than just one, which ensures that these new expressions retain the
behavior of implicitly converting to the source type before running the
conversion. The new conversion functions only specify target type, and so
cannot guarantee identical results if the argument type does not exactly
match what was previously given as the parameter type in HIL.
2019-02-20 21:53:12 +01:00
|
|
|
|
|
|
|
# Undocumented HIL implementation details that some users nonetheless relied on.
|
|
|
|
conv_bool_to_string = tostring(tobool(true))
|
|
|
|
conv_float_to_int = floor(1.5)
|
|
|
|
conv_float_to_string = tostring(tonumber(1.5))
|
|
|
|
conv_int_to_float = floor(1)
|
|
|
|
conv_int_to_string = tostring(floor(1))
|
|
|
|
conv_string_to_int = floor(tostring("1"))
|
|
|
|
conv_string_to_float = tonumber(tostring("1.5"))
|
|
|
|
conv_string_to_bool = tobool(tostring("true"))
|
2018-12-01 03:23:09 +01:00
|
|
|
}
|