HCL is the HashiCorp configuration language.
Defaults
struct and associated functions can apply additional and more flexible 'unsafe' conversions (examples include tuples into collections such as lists and sets, and additional safety around null and dynamic values). (#564)cty.Value
, rather than after, if they require a specific cty.Type
. (#564)TypeConstraint
. Attributes can be wrapped in the special optional(…)
modifier, allowing the attribute to be omitted while still meeting the type constraint. For more information, cty's documentation on conversion between object types. (#549)TypeConstraintWithDefaults
. In this mode, the optional(…)
modifier accepts a second argument which can be used as the default value for omitted object attributes. The function returns both a cty.Type
and associated Defaults
, the latter of which has an Apply
method to apply defaults to a given value. (#549)TokensForTuple
, TokensForObject
, and TokensForFunctionCall
allow for more easily constructing the three constructs which are supported for static analysis and which HCL-based languages typically use in contexts where an expression is used only for its syntax, and not evaluated to produce a real value. For example, these new functions together are sufficient to construct all valid type constraint expressions from the Type Expressions Extension, which is the basis of variable type constraints in the Terraform language at the time of writing. (#502)IsJSONExpression
and IsJSONBody
to determine if a given expression or body was created by the JSON syntax parser. In normal situations it's better not to worry about what syntax a particular expression/body originated in, but this can be useful in some trickier cases where an application needs to shim for backwards-compatibility or for static analysis that needs to have special handling of the JSON syntax's embedded expression/template conventions. (#524)function.ArgError
whose argument index is out of range for the length of the arguments. Previously this would often lead to a panic, but now it'll return a less-precice error message instead. Functions that return out-of-bounds argument indices still ought to be fixed so that the resulting error diagnostics can be as precise as possible. (#472)hcl.Index
and hcl.GetAttr
. These are part of the implementation of indexing and attribute lookup in the native syntax expression language too, so the new error messages will apply to problems using those operators. (#474)${
... }
template interpolation sequences will now produce an extra hint message about the need to escape as $${
when trying to include interpolation syntax for other languages like shell scripting, AWS IAM policies, etc. (#462)