fix: don't use existing context when evaluating resources, data or provider blocks #3075
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
SetByDot
function handles the merging anyway, so we don't need to pull out the existing values. I've left the old functionality in theevaluateResource
andevaluatorProvider
functions because the legacy evaluator needs it.This also fixes an issue where the data blocks were using
e.ctx.Get(b.TypeLabel())
which was getting the wrong context. The correct functionality would have been to usee.ctx.Get("data")
. Otherwise, this caused issues where the type of a data block matched the name of a resource, e.g.data.aws_lb.anything
andaws_lb.aws_lb
. In this case it would pull the context of the resource, which could cause a panic if the resource had been expanded, because it would be an array instead of the expected map.