Commit graph

12 commits

Author SHA1 Message Date
Radek Simko
0fe906fa8c make copyrightfix 2026-02-17 13:56:34 +00:00
Liam Cervante
e78294d42b
stacks: stop encoding values into msgpack twice (#35734) 2024-09-18 10:18:01 +02:00
Liam Cervante
f8fe397d88
stacks: add removed block functionality (#35671)
* stacks: add removed block functionality

* fix compile errors
2024-09-07 14:36: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
7163c4b6d5
stacks: fix destroy ordering of stacks destroy plans (#35665)
* stacks: remove unneeded required components functions

* stacks: refactor the mock provider for realism

* deferred actions: fix missing features in deletions

* stacks: fix destroy ordering of stacks destroy plans

* fix missing import
2024-09-05 12:10:24 +02:00
Liam Cervante
915b174da3
stacks: split the terraform1 RPC package into per-service packages (#35513)
* stacks: split the terraform1 RPC package into per-service packages

* pull latest changes
2024-08-07 17:33:51 +02:00
Martin Atkins
30e2fd6525 Handle marks a little more consistently
In the very first implementation of "sensitive values" we were
unfortunately not disciplined about separating the idea of "marked value"
from the idea of "sensitive value" (where the latter is a subset of the
former). The first implementation just assumed that any marking whatsoever
meant "sensitive".

We later improved that by adding the marks package and the marks.Sensitive
value to standardize on the representation of "sensitive value" as being
a value marked with _that specific mark_.

However, we did not perform a thorough review of all of the mark-handling
codepaths to make sure they all agreed on that definition. In particular,
the state and plan models were both designed as if they supported arbitrary
marks but then in practice marks other than marks.Sensitive would be
handled in various inconsistent ways: dropped entirely, or interpreted as
if marks.Sensitive, and possibly do so inconsistently when a value is
used only in memory vs. round-tripped through a wire/file format.

The goal of this commit is to resolve those oddities so that there are now
two possible situations:
 - General mark handling: some codepaths genuinely handle marks
   generically, by transporting them from input value to output value in
   a way consistent with how cty itself deals with marks. This is the
   ideal case because it means we can add new marks in future and assume
   these codepaths will handle them correctly without any further
   modifications.
 - Sensitive-only mark preservation: the codepaths that interact with our
   wire protocols and file formats typically have only specialized support
   for sensitive values in particular, and lack support for any other
   marks. Those codepaths are now subject to a new rule where they must
   return an error if asked to deal with any other mark, so that if we
   introduce new marks in future we'll be forced either to define how we'll
   avoid those markings reaching the file/wire formats or extend the
   file/wire formats to support the new marks.

Some new helper functions in package marks are intended to standardize how
we deal with the "sensitive values only" situations, in the hope that
this will make it easier to keep things consistent as the codebase evolves
in future.

In practice the modules runtime only ever uses marks.Sensitive as a mark
today, so all of these checks are effectively covering "should never
happen" cases. The only other mark Terraform uses is an implementation
detail of "terraform console" and does not interact with any of the
codepaths that only support sensitive values in particular.
2024-04-18 07:32:52 -07:00
Martin Atkins
6071e06f1a tfstackdata1: DynamicValueFromTFStackData1 decodes sensitive marks 2024-01-08 13:41:42 -08:00
Martin Atkins
a4d61733f6 stackplan: Include extra info in raw component instance plan
We'll now track the planned action, the component addresses we depend on,
and the planned output values.
2024-01-08 10:52:01 -08:00
Martin Atkins
bcccd67e32 tfstackdata1: A local DynamicValue message type
Previously we were directly using the planproto.DynamicValue message type,
but that's symmetrical with plans.DynamicValue in that it encodes only
the value itself and not associated metadata such as the paths that have
sensitive value marks.

This new tfstackdata1.DynamicValue therefore echoes
terraform1.DynamicValue by carrying both the value and the metadata
together.

This implies a slight change to one of the existing message types that
was encoding a map of planned input values for each component instance,
but in practice we're not currently making use of that data anyway -- it's
there to enable a hypothetical extra correctness check in the stacks
runtime so that we can detect inconsistency problems closer to their
source -- and so this change doesn't affect anything in practice. Before
we make use of it we'll probably want to change the internal API a little
so that we can preserve the sensitive value metadata on those values, but
that's beyond the scope of this PR.

The main point of adding this is to track the output values for a component
instance as part of the raw state, and so the new field for that is also
added here although nothing will read or write it yet. Actual use of that
new field will follow in future commits.
2023-12-08 10:20:20 -08:00
Martin Atkins
8fd29e9439 stacks: Preserve prior state from plan to apply
We need to retain the prior state (in a form that Terraform Core's modules
runtime can accept) between the plan and apply phases because Terraform
uses it to verify that the provider's "final plan" is consistent with
the initial plan.

We previously tried to do this by reusing the "old" value from the planned
change, but that's not really possible in practice because of the
historical implementation detail that Terraform wants state information
in a JSON format and plan information in MessagePack.

This also contains the beginnings of handling the "discarding" of
unrecognized keys from the state data structures, although we'll probably
need to do more in that area later since this is just the bare minimum.
2023-11-15 12:38:56 -08:00
Martin Atkins
54622c68a5 stackstate: Generate "raw state" objects for resource instance objects
Previously we just had a stub that only generated basic external
description objects. Now we'll also emit "raw state" objects for these,
and have some initial support for deposed objects too.
2023-11-15 12:38:55 -08:00