Skip to content
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

Backport of hcl2template: recursively evaluate local variables into release/1.11.x #13055

Conversation

hc-github-team-packer
Copy link
Collaborator

Backport

This PR is auto-generated from #13039 to be assessed for backporting due to the inclusion of the label backport/1.11.x.

The below text is copied from the body of the original PR.


The logic for evaluating local variables used to rely on their definition order, with some edge cases.
Typically locals blocks define multiple local variables, which don't necessarily appear in the same order at evaluation as within the template, leading to inconsistent behaviour, as the order in which those are added to the list of local variables is non-deterministic.

To avoid this problem, we change how local variables are evaluated, and we're adopting a workflow similar to datasources, where the local variables first build a list of direct dependencies.
Then when evaluation happens, we evaluate all the dependencies recursively for each local variable, which takes care of this issue.

As with Datasources, we add a cap to the recursion: 10. I.e. if the evaluation of a single variable provokes an infinite recursion, we stop at that point and return an error to the user, telling them to fix their template.

Closes: #13018


Overview of commits

@hc-github-team-packer hc-github-team-packer requested a review from a team as a code owner June 17, 2024 20:52
@hc-github-team-packer hc-github-team-packer force-pushed the backport/fix_locals_eval_order/hugely-welcome-rodent branch from f4021be to bdcf68d Compare June 17, 2024 20:52
@hc-github-team-packer hc-github-team-packer merged commit fae9a4e into release/1.11.x Jun 17, 2024
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants