-
Notifications
You must be signed in to change notification settings - Fork 345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
terraform: Remove unused internal packages impl #1158
Conversation
12d6466
to
fbe99fb
Compare
fbe99fb
to
3378fb8
Compare
GetForEachAttr(addrs.ForEachAttr, tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics) | ||
GetResource(addrs.Resource, tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics) | ||
GetLocalValue(addrs.LocalValue, tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics) | ||
GetModule(addrs.ModuleCall, tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, evaluation is only supported for input variables, path, and terraform attributes, so remove the others.
// object and instance key data. References to the object must use self, and the | ||
// key data will only contain count.index or each.key. The static values for | ||
// terraform and path will also be available in this context. | ||
func (s *Scope) EvalSelfBlock(body hcl.Body, self cty.Value, schema *configschema.Block, keyData instances.RepetitionData) (cty.Value, tfdiags.Diagnostics) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, evaluation of self.*
is not supported by TFLint.
// First we'll do static validation of the references. This catches things | ||
// early that might otherwise not get caught due to unknown values being | ||
// present in the scope during planning. | ||
if staticDiags := s.Data.StaticValidateReferences(refs, selfAddr); staticDiags.HasErrors() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StaticValidateReferences
mainly detect reference errors of resources, data attributes, module attributes early. However, TFLint does not support the evaluation of these attributes.
@@ -72,7 +48,7 @@ func (e *Evaluator) Scope(data lang.Data, self addrs.Referenceable) *lang.Scope | |||
return &lang.Scope{ | |||
Data: data, | |||
SelfAddr: self, | |||
PureOnly: e.Operation != walkApply && e.Operation != walkDestroy && e.Operation != walkEval, | |||
PureOnly: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The initial value is always used for the e.Operation
. This affects the behavior of some functions, and it is arguable whether this PureOnly: true
is appropriate for TFLint evaluation, but it follows current behavior.
See also #1141
In #1141, I just copied the internal packages needed to build TFLint from Terraform v1.0. However, this includes obviously unused implementations. This PR reduces the implementations that need to be maintained by reviewing some features such as evaluation.
This change is made without changing the TFLint interface. Changing the interface may reduce more implementations, but it will be done in other PRs.