You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes a ruleset developer wants to walk every expression and evaluate it. This can be easily achieved using the WalkExpressions and EvaluateExpr APIs.
However, some expressions depend on the context around them, and this approach can cause errors when evaluated. Some examples that are currently known are:
Because a for expression has its own scope, the expression inside may not be uniquely determined unless the for expression is expanded. For example, it is not possible to evaluate only "value is ${x}" in for x in [1, 2]: "value is ${x}".
The ignore_changes cannot be evaluated because it is a special reference that is different from other expressions. Something similar is the provider reference.
There are other expressions that are not statically determined, such as self references and count/each, but these are already treated as unknown by TFLint, so no error occurs. Only references that do not contain periods, such as x and tags (in other words, references that are not treated as valid by ReferencesInExpr), will cause an error.
The simplest solution would be to just treat any reference that does not contain a period as an unknown value, but this has the problem of being too permissive compared to the Terraform language evaluation system, since this is an expression that should result in an error in a typical expression evaluation context.
Anyway, somehow we eliminate these unevaluable expression patterns and make all partial expression evaluation possible.
The text was updated successfully, but these errors were encountered:
See also terraform-linters/tflint-ruleset-terraform#199
Sometimes a ruleset developer wants to walk every expression and evaluate it. This can be easily achieved using the
WalkExpressions
andEvaluateExpr
APIs.However, some expressions depend on the context around them, and this approach can cause errors when evaluated. Some examples that are currently known are:
"value is ${x}"
infor x in [1, 2]: "value is ${x}"
.ignore_changes
cannot be evaluated because it is a special reference that is different from other expressions. Something similar is the provider reference.There are other expressions that are not statically determined, such as
self
references andcount
/each
, but these are already treated as unknown by TFLint, so no error occurs. Only references that do not contain periods, such asx
andtags
(in other words, references that are not treated as valid byReferencesInExpr
), will cause an error.The simplest solution would be to just treat any reference that does not contain a period as an unknown value, but this has the problem of being too permissive compared to the Terraform language evaluation system, since this is an expression that should result in an error in a typical expression evaluation context.
Anyway, somehow we eliminate these unevaluable expression patterns and make all partial expression evaluation possible.
The text was updated successfully, but these errors were encountered: