Commit graph

29 commits

Author SHA1 Message Date
Mutahhir Hayat
7aa0a71078 Create Protobuf changes for stack planning that includes Action invocations 2026-03-02 17:08:15 +01:00
Radek Simko
0fe906fa8c make copyrightfix 2026-02-17 13:56:34 +00:00
Liam Cervante
063757ff45
stacks: refactor plan, state, and removed tracking with tree structures for efficient lookups (#36850) 2025-04-16 14:05:51 +02:00
Liam Cervante
a06f82746a
stacks: update removed blocks to allow targeting of embedded stacks (#36814)
* stacks: update removed blocks to allow targeting of embedded stacks

* copywrite headers
2025-04-04 15:01:37 +02:00
Liam Cervante
2b5101f734
stacks: include existing components when deferring nested stacks (#36788)
* stacks: include existing components when deferring nested stacks

* improve comments
2025-04-03 10:40:28 +02:00
Liam Cervante
fbd5a7930e
stacks: allow removed blocks to target components in nested stacks (#36787)
* stacks: allow removed blocks to target components in nested stacks

* make copywrite fix

* fix comments
2025-04-03 10:29:18 +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
71dbc7d726
migrate command for terraform stacks (#36482) 2025-03-19 10:39:50 +01:00
Liam Cervante
d142486a40
stacks: expand plan and apply outputs for inputs (#35724) 2024-09-16 11:45:19 +02:00
Liam Cervante
73e3f8096b
stacks: complete stack output implementation for plan and apply (#35723) 2024-09-16 11:36:36 +02:00
Liam Cervante
36971f6ee8
stacks: add support for the removed block to .tfstacks.hcl (#35669) 2024-09-05 12:22:16 +02:00
Liam Cervante
0f0414d484
Fix partial address representation in plan for deferred actions (#34966)
* Fix partial address representation in plan

* reflect new type in stacks
2024-06-20 10:41:23 +02:00
Liam Cervante
b646dff26a
stacks: apply nested default values to inputs (#35349)
* stacks: apply nested default values to inputs

* group similar tests
2024-06-18 12:03:43 +02:00
Martin Atkins
1714729f87 stackeval: terraform.applying symbol
This symbol produces an ephemeral boolean value that's true when the
stack evaluator is configured for applying and false otherwise.

The primary purpose of this is to allow specifying a more privileged auth
role in a provider configuration during the apply phase, while allowing
the plan phase to use a read-only or otherwise-less-privileged role.
2024-06-17 08:34:46 -07:00
Martin Atkins
5bfdb12098 stackaddrs: Absolute references and referenceables
This allows us to talk about references between expressions in absolute
terms, taking into account the stack where a particular expression would
be resolved.

This isn't an appropriate representation for references like each.key,
since those require a more specific scope than just a stack, but that's
okay because those contextual reference types can't depend on anything
other than what they are embedded inside anyway, and so we never need to
consider them when we're doing global reference analysis.
2024-01-08 10:52:01 -08:00
Martin Atkins
8a99c3c0e5 stacks+rpcapi: Add some missing copyright comments 2023-11-15 12:38:57 -08:00
Martin Atkins
333c502990 stackeval: Support each.key, each.value, count.index and self references
For all contexts where these have a defined value, they can now be used
in expressions and evaluate to whatever they ought to evaluate to.
2023-11-15 12:38:56 -08:00
Martin Atkins
13edd30479 stackeval: Test-only globals
Because many stacks language features are dependent on others to do useful
work, it's tempting to focus only on integration testing of combinations
of features used together. However, we known from our experience with the
modules runtime (the "terraform" package) that over time this becomes a
huge maintenance burden, because any non-trivial change tends to
invalidate hundreds or thousands of integration tests, and because of their
broad scope its often hard in retrospect to figure out what exactly a
particular test was aiming to test vs. what it was just relying on as a
side-effect.

To try to minimize these cross-dependencies and thus enable something
closer to unit testing, here we introduce a special kind of symbol to the
stacks language which is available only to unit tests in this package.
"Test-only globals" -- an intentionally-clunky name to avoid squatting on
useful names -- can be set as part of the Main object and, when defined,
are available for use in all situations where we perform expression
evaluation against a stack. The "globals" in the name represents that,
unlike just about everything else, they are defined once but available in
all stacks in the configuration tree.

This design is a tradeoff: it introduces a bunch of extra code that is
here entirely to support testing, but hopefully this code is segregated
enough from everything else that it's unlikely to change significantly
under future maintenance, thereby hopefully minimizing the need for future
cross-cutting test maintenance too.
2023-11-15 12:38:56 -08:00
Martin Atkins
89776cd2a6 stackstate: Initial work on decoding and the state model
This is a sketch of the overall structure of the prior state decoder and
the model type it populates.

Before we can complete this we'll need to slightly rework how the apply
phase emits the raw events that this is consuming, and in particular to
change the raw state representation to be JSON-based to match with how
Terraform Core expects to receive it once reloaded. That will follow in
later commits.
2023-11-15 12:38:55 -08:00
Martin Atkins
434e199675 stackaddrs: Add HashiCorp copyright comments 2023-11-15 12:38:55 -08:00
Martin Atkins
f347d0a441 stackaddrs: Handle instance keys in embedded stack references
Previously this logic was wrong, because it had already consumed the two
leading traversal steps before checking if there was anything else.
2023-11-15 12:38:55 -08:00
Martin Atkins
385e37cae2 stackaddrs: fix some ParseAbsComponentInstance logic errors 2023-11-15 12:38:55 -08:00
Martin Atkins
c1e7abafc3 stackruntime: Configure and assign provider instances
Instead of the temporary hack of hard-coding the built-in "terraform"
provider, it's now possible to declare configurations for arbitrary
providers and assign them to the provider configuration slots of the root
module of each component.
2023-11-15 12:38:54 -08:00
Martin Atkins
edc02f2a06 stackaddrs: ConfigComponentForAbsInstance
This helper discards all of the instance keys from an AbsComponentInstance
to find the corresponding ConfigComponent.
2023-11-15 12:38:52 -08:00
Martin Atkins
ebab67b468 stackaddrs: AbsComponentInstance address parsing
Addresses of this type will appear in some of our serialization formats
and so we need a parser function which provides the inverse of the
"String" method of this type.
2023-11-15 12:38:51 -08:00
Martin Atkins
e0797ab913 stackaddrs: Addresses for things inside components
In the stacks model a component is essentially a container for a tree of
normal Terraform modules, and so anything that can appear in a Terraform
module can in principle appear inside a component.

With that in mind here we define a generic type that can represent
anything from package addrs belonging either to a stack configuration
(before instance expansion) or to a stack instance (after instance
expansion), and some aliases for a few combinations that make sense
together, such as stackaddrs.AbsResourceInstance being an
addrs.AbsResourceInstance belonging to a stackaddrs.AbsComponentInstance.

We'll probably add more aliases here later, but this is a starting set
that I expect will arise while implementing the planning-related models
for stacks.
2023-11-15 12:38:51 -08:00
Martin Atkins
59a044dd6f stackeval: The naming of promises
If a stack configuration has a dependency cycle we'll tend to detect it
by the promises failing to resolve due to a self-reference. Describing
that situation to end-users has been historically hard in existing
Terraform's dag-based implementation, and there are some similar
challenges for this promise-based design too.

To deal with it while minimizing runtime overhead in the happy path we'll
teach the various objects to retroactively report names for the promises
they've already instantiated and then only when we encounter the
ErrSelfDependent error will we walk the tree of objects to find
user-friendly names for all of the promises that have contributed to the
results so far.
2023-11-15 12:38:51 -08:00
Martin Atkins
3d503f8e71 stackruntime: Stubbing the "interpreter" for stack configurations 2023-11-15 12:38:51 -08:00
Martin Atkins
e667352553 stacks/stackaddrs: Initial address types for stacks
This serves a similar purpose to the "addrs" package for Terraform overall,
but deals with concepts that are unique to the stacks language.
2023-11-15 12:38:50 -08:00