Commit graph

33 commits

Author SHA1 Message Date
Mutahhir Hayat
e133339a83 Add test for planned action invocation hooks, and ensuring the plan is valid 2026-03-06 14:00:31 +01:00
Daniel Schmidt
2077b53936 add tests for dynamic module sources in stacks 2026-03-05 16:24:51 +01:00
Radek Simko
0fe906fa8c make copyrightfix 2026-02-17 13:56:34 +00:00
Liam Cervante
15a6cd208b
stacks: fix diagnostic referring to tfstacks command (#37639) 2025-09-19 10:22:03 +02:00
Liam Cervante
2a1b4c3ed4
Update go-cty and HCL for 1.13 release (#37298) 2025-07-09 13:05:18 +02:00
Liam Cervante
a80220dcc9
stacks: rename .tfstack files to .tfcomponent (#37013)
* stacks: rename .tfstack files to .tfcomponent

* fix consistency issues
2025-05-15 08:33:13 +02:00
Liam Cervante
f82ae44484
stacks: make promises identify themselves (#36749)
* stacks: refactor promises so they declare id when starting

* stacks: add some missing perEval promises

* formatting
2025-03-26 13:25:45 +01:00
Samsondeen
8b7e7ad27d
Detect circular references during Validation (#36709) 2025-03-19 10:39:23 +01:00
Liam Cervante
0ae6bc34c4
stacks: introduce shared functions for common tests (#35718) 2024-09-12 16:16:15 +02:00
Liam Cervante
cf49545b5a
stacks: include removed blocks during validate command (#35680) 2024-09-07 15:04:14 +02:00
Liam Cervante
436b72b63b
stacks: fix memory leak caused by unclosed providers (#35678)
* stacks: make the mock provider error if it's not cleaned up

* stacks: start and clean up unconfigured clients once
2024-09-07 14:22:16 +02:00
Liam Cervante
b6ac98122b
stacks: refactor shared functionality in prep for removed blocks (#35670) 2024-09-05 13:15:53 +02:00
Liam Cervante
7660d8d086
stacks: fix suggested command when lock file is out of date (#35616) 2024-08-21 09:32:08 +02:00
Liam Cervante
5939efb798
stacks: add depends_on for embedded stacks and components (#35549) 2024-08-12 15:02:36 +02:00
Liam Cervante
33c0ae7f09
stacks: add additional provider validation tests (#35471) 2024-07-26 11:36:08 +02:00
Liam Cervante
8e47b5907c
stacks: provide more helpful diagnostics when providers types are mismatched (#35422)
* stacks: provide more helpful diagnostics when providers types are mismatched

* remove left over implementation experiments

* remove unnecessary fmt.Sprintf

* address comments

* fix incorrect pluralisation

* fix tests
2024-07-08 10:31:52 +02:00
Daniel Schmidt
bf5037fa05
stacks: add test case 2024-07-03 14:43:04 +02:00
Daniel Schmidt
05755422f3
stacks: pass dependency lock in tests 2024-07-03 14:42:25 +02:00
Liam Cervante
7a8ffff66e
stacks: Fix unknown provider values crashing validation phase (#35155)
* test to reproduce

* stacks: Fix unknown provider values crashing validation phase

* remove extra type information

---------

Co-authored-by: CJ Horton <cjhorton@hashicorp.com>
2024-05-16 13:06:13 +02:00
Alisdair McDiarmid
f3ec86b17b stackruntime: Treat unset and null equally
When handling root input variable values, we now consider unset and null
values to be equivalent to each other. This is consistent with how we
handle variables in embedded stacks, and very similar to how we handle
variable in the modules runtime with `nullable = false`.

One difference from the modules runtime case is that we do not prevent
a null default value for stack variables.
2024-03-07 15:49:39 -05:00
Alisdair McDiarmid
0fe26468cd stackruntime: Apply defaults to root variables
When evaluating a stack's root input variables, supplied by the caller,
we must apply any default values specified in the variable
configuration for variables with no specified value. This commit adds
this default fallback case, using NilVal as a marker indicating the lack
of a specified value.

If no default value exists for a variable, it is therefore required to
be supplied by the caller. This commit also reports a diagnostic error
in this case.
2024-03-04 16:20:17 -05:00
Liam Cervante
cec4b7b74c
stacks: validate providers based on types instead of local names (#34735)
* stacks: validate providers based on types instead of local names

* fix tests
2024-02-28 08:24:53 +01:00
Liam Cervante
31a7fa88d5
stacks: validate provider configurations during static analysis (#34730) 2024-02-27 08:43:58 +01:00
Alisdair McDiarmid
1459825e53
Merge pull request #34725 from hashicorp/alisdair/configs-sourcebundle-parser
Add and use a source bundle aware configuration parser for stacks
2024-02-26 16:39:33 -05:00
Liam Cervante
b2cc7dbadf
stacks: validate the types of input variables during validation (#34722) 2024-02-26 11:36:19 +01:00
Liam Cervante
831630fabe
stacks: the plan function should stop on validation errors (#34720) 2024-02-26 10:42:14 +01:00
Alisdair McDiarmid
97a220fb82 stacks: Use source bundle aware config parser 2024-02-23 13:29:37 -05:00
Liam Cervante
b3abff5750
stacks: check providers blocks in components during validatation (#34707) 2024-02-21 11:07:51 +01:00
Liam Cervante
bced645a4d
stacks: call terraform.Validate on stack component configs (#34705) 2024-02-21 10:58:44 +01:00
Martin Atkins
d1b0632e82 stackruntime: Add HashiCorp copyright comments 2023-11-15 12:38:55 -08:00
Martin Atkins
ea3b70abf0 stackeval: Component calls are now referenceable
This means it's valid to write references like "component.foo" in
expressions in a stack configuration, where the result is built from the
planned output values of the root module of each component instance.

For embedded stacks we intentionally designed the language to require
explicit types on all output values so that we'd still be able to do type
checking even when we can't calculate the output values yet. Unfortunately
we can't do the same trick for components because the main Terraform
module language treats output values as dynamically-typed and so an
output value we can't evaluate yet could have literally any type.

Therefore we concede and just return cty.DynamicVal in most failure cases
here; perhaps a future edition of the main Terraform language can improve
this by requiring explicitly-typed output values there too.
2023-11-15 12:38:53 -08:00
Martin Atkins
791a5fb8a6 stackruntime: Top-level "Validate" function
This is the public entry point for the overall validation of an entire
stack configuration. So far it supports validation only of input variables,
embedded stack calls, and output values. We'll grow this to support other
language constructs in later commits.

This is a relatively large commit due to introducing various supporting
infrastructure to help make evaluation possible at all. Subsequent commits
will hopefully be more focused due to being able to depend on the
foundations introduced here.
2023-11-15 12:38:51 -08:00
Martin Atkins
4754889950 stackruntime: Beginnings of Validate function
This stubs out the basic structure of stackeval's equivalent of a graph
walk, which is really just a recursive tree walk starting async tasks that
might depend on each other via the abstractions in package "promising".

This initial work is sufficient to validate the inputs to an embedded
stack call when referring to input variables in the calling stack, showing
that the expression evaluation model seems to be working and the use of
promises to deal with dependency ordering seems viable.
2023-11-15 12:38:51 -08:00