* properly parse actions during configuration loading
* parse action expression during ActionPlanTransformer transform
* fix: properly parse action expressions (not traversals)
Previously, we were storing action and linkedResource expressions as Traversals during config loading. This PR replaces those fields with hcl.Expression, moves some validation around to account for the fact we don't have fully evaluated traversals yet (some checks have been removed entirely and will be replaced in a follow up PR, I wanted to get this right first), and finally moves the actual evaluation into the terraform graph build phase.
I added a permissive parsing of the ActionExpression during ActionPlanTransformer.transformSingle (to get the config action) and store the action expression inside the nodeActionTriggerPlanExpand.lifecycleActionTrigger so it can be fully evaluated (with access to the resource's repetition data, which is necessary if the action in the resource's lifecycle block uses count.index or for_each.key) during nodeActionTriggerPlanExpand.DynamicExpand
Finding references in an expression is a static analysis operation, but
we previously had it grouped in with "package lang" that primarily deals
with dynamic evaluation of expressions.
We need to do static analysis in far more locations than we do full
expression evaluation, the static-analysis-only callers don't need anything
else from package lang, and the reference-analysis functions are
self-contained little wrappers around the address parsing logic in
package addrs anyway.
Splitting these into a separate package therefore minimizes which packages
depend indirectly on package lang, and thus which packages depend
indirectly on the implementations of the built-in functions. Some of the
built-in functions rely on dependencies we don't use anywhere else, so
cutting these out shrinks how many packages indirectly depend on those
external dependencies. In particular, they are no longer in the indirect
import chain for the "legacy" module.
The previous name didn't fit with the naming scheme for addrs types:
The "Abs" prefix typically means that it's an addrs.ModuleInstance
combined with whatever type name appears after "Abs", but this is instead
a ModuleCallOutput combined with an InstanceKey, albeit structured the
other way around for convenience, and so the expected name for this would
be the suffix "Instance".
We don't have an "Abs" type corresponding with this one because it would
represent no additional information than AbsOutputValue.
This is part of a general effort to move all of Terraform's non-library
package surface under internal in order to reinforce that these are for
internal use within Terraform only.
If you were previously importing packages under this prefix into an
external codebase, you could pin to an earlier release tag as an interim
solution until you've make a plan to achieve the same functionality some
other way.
This is part of a general effort to move all of Terraform's non-library
package surface under internal in order to reinforce that these are for
internal use within Terraform only.
If you were previously importing packages under this prefix into an
external codebase, you could pin to an earlier release tag as an interim
solution until you've make a plan to achieve the same functionality some
other way.
This is part of a general effort to move all of Terraform's non-library
package surface under internal in order to reinforce that these are for
internal use within Terraform only.
If you were previously importing packages under this prefix into an
external codebase, you could pin to an earlier release tag as an interim
solution until you've make a plan to achieve the same functionality some
other way.
2021-05-17 14:09:07 -07:00
Renamed from command/jsonconfig/expression.go (Browse further)