packer/packer_test
Lucas Bajolet 14cf4b40d4 hcl2template: recursively evaluate local variables
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.
2024-06-17 16:51:58 -04:00
..
plugin_tester build(deps): bump golang.org/x/net in /packer_test/plugin_tester 2024-06-12 11:55:32 -04:00
templates hcl2template: recursively evaluate local variables 2024-06-17 16:51:58 -04:00
base_test.go packer_test: compile packer with .exe for Windows 2024-06-10 09:59:32 -04:00
commands_test.go packer_test: disable checkpoint for test cmds 2024-06-17 16:51:58 -04:00
gadgets_test.go packer_test: add convenience func for line count 2024-06-10 09:59:32 -04:00
init_test.go packer_test: add SkipNoAcc function 2024-06-17 16:51:58 -04:00
install_test.go packer_test: add SkipNoAcc function 2024-06-17 16:51:58 -04:00
loading_test.go packer_test: add test with config.json/components 2024-06-10 09:59:32 -04:00
local_eval_test.go hcl2template: recursively evaluate local variables 2024-06-17 16:51:58 -04:00
pipe_checker_test.go packer_test: don't error on empty pipeline 2024-06-10 09:59:32 -04:00
plugin_test.go packer_test: remove %d from workdir path 2024-06-10 09:59:32 -04:00
plugins_remove_test.go packer_test: Add tests for invalid plugin remove use cases 2024-06-10 09:59:32 -04:00
sample_config.json packer_test: add test with config.json/components 2024-06-10 09:59:32 -04:00
suite_test.go packer_test: add SkipNoAcc function 2024-06-17 16:51:58 -04:00