Commit Graph

2752 Commits

Author SHA1 Message Date
Andrei Ciobanu
4eaa76c435 Add notes on the backend flags initialisation for future refactor
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-01-26 17:28:55 +02:00
Andrei Ciobanu
dc7ff7ed9a Extract RemoteVersionCheck from Meta
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-01-26 15:17:06 +02:00
Andrei Ciobanu
032aa174bf This is a working state for the binary. Tests still broken
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-01-26 14:56:13 +02:00
Andrei Ciobanu
fec5baa07c TMP
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-01-23 17:12:29 +02:00
Andrei Ciobanu
8e808f3cc2 Make it clear for the external key providers when it needs to generate decryption key (#3672)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-01-27 12:20:23 +02:00
Andrei Ciobanu
c7f46c713a Enhance the documentation and the integration tests for the pg backend (#3700)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-01-27 10:17:07 +02:00
Andrei Ciobanu
d088667ed7 Fix a hard to catch race condition in providers installation process (#3702)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-01-23 15:34:25 +02:00
James Humphries
c4f49afc10 Use explicit NoKey check instead of assuming nil in v3 upgrade (#3696)
Signed-off-by: James Humphries <james@james-humphries.co.uk>
2026-01-20 14:25:40 -05:00
Christian Mesh
6280691025 Support dual output streams in most commands (#3606)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Co-authored-by: Diógenes Fernandes <diofeher@gmail.com>
2026-01-20 14:08:10 -05:00
Diógenes Fernandes
0a631be1d6 Provider validation for enabled at module calls (#3680)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2026-01-20 13:06:22 -03:00
Denis O
9dbb5fcb9c Error checking simplifications (#3694)
Signed-off-by: Denis O <denis.o@linux.com>
2026-01-20 09:27:14 +00:00
yy
4a86a1233c fix: typos in comments (#3691)
Signed-off-by: Yohei Yamamoto <yhymmt123@gmail.com>
2026-01-19 13:46:12 +00:00
Martin Atkins
2e09323694 engine/applying: First somewhat-working implementation
This is just enough to connect all of the apply engine parts together into
a functional whole which can at least attempt to apply a plan. There are
various gaps here that make this not fully work in practice, but the goal
of this commit is to just get all of the components connected together in
their current form and then subsequent commits will gradually build on this
to make it work better.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-01-16 09:50:36 -08:00
Martin Atkins
4641cb8b2f engine/applying: Execution graph compilation and other stubbing
This is just some initial sketching of how the applying package might do
its work. Not yet finished, and I'm expecting to change about the
execution graph operations in future commits now that the main plan/apply
flow is plumbed in and so it's easier to test things end-to-end.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-01-16 09:50:36 -08:00
Martin Atkins
d8d21619a4 backend/local: Initial setup for the new runtime's "apply" command
This is just enough to get the plan object and check that it has the
execution graph field populated, and to load the configuration. More to
come in later commits.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-01-16 09:50:36 -08:00
Martin Atkins
f4d4a21925 command: Enable experimental runtime in BackendForLocalPlan
We previously added a check like this to the Meta.Backend method, but we
use Meta.BackendForLocalPlan instead when we're applying a saved plan, so
we need to make sure the setting gets propagated here too or else the
experimental codepath cannot be entered by the "tofu apply" command.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-01-16 09:50:36 -08:00
Martin Atkins
6cb6952fce engine/planning: Track dependencies between resource instances
This makes explicit the relationships between resource instances so that
they'll be honored automatically when we actually execute the graph.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-01-16 09:50:36 -08:00
Martin Atkins
4e07f8949c lang/eval: Populate DesiredResourceInstance.RequiredResourceInstances
The dependencies of a resource instance are based primarily on the marks
in the configuration value, and so we'll decide them as part of the same
function that decides the configuration value.

We then need to propagate that result through all of the intermediate
layers to the code that actually constructs the DesiredResourceInstance
object, at which point it's then available to the planning engine. In a
future commit the planning engine will use it to record the resource
instance dependencies explicitly in the generated execution graph.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-01-16 09:50:36 -08:00
Martin Atkins
78ecc7b996 internal/execgraph: Builder.ProviderInstance must memoize
The whole point of this helper is to encapsulate the concern of having
exactly one open/close pair for each distinct provider instance address, so
in order to be effective it must actually save its results in the same
map it was already checking!

This was just an oversight in the original implementation that became more
apparent after having a visualization of execution graphs, since that made
it far more obvious that we were previously planning to open a separate
provider instance per resource instance.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-01-16 09:50:36 -08:00
Martin Atkins
8f16d60d65 backend/local: New runtime impl can save plan files
This should be just enough saved plan file support to help us get an
execution graph saved so that it can be used in a subsequent apply step,
once we implement that.

As usual with the new runtime, the traditional plan file format is mainly
just acting as a vessel to transport the execution graph and so we need to
make it valid enough that the plan loader can load it but don't need to
make it fully consistent. Therefore for now the config snapshot is just
stubbed out as empty, with the assumption that our initial "walking
skeleton" implementation will just use the loose config files on disk for
now.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-01-16 09:50:36 -08:00
Martin Atkins
9300e922e8 engine/planning: Populate ProviderAddr in planned changes
In order to produce a valid saved plan file we need to save information
about which provider instance each resource instance belongs to. We're
probably not actually going to use this information in the new
implementation because the same information is captured as part of the
execution graph, but we do at least need to make this valid enough that the
plan file loading code will accept it, because right now (for experimental
purposes) we're smuggling the execution graph through our traditional plan
file format as a sidecar data structure.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-01-16 09:50:36 -08:00
Martin Atkins
f2184552ee engine/planning: Tolerate invalid plans from Terraform Plugin SDK
As with the traditional runtime, we need to tolerate invalid plans from
providers that announce that they are implemented with the legacy Terraform
Plugin SDK, because that SDK is incapable of producing valid plans.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-01-16 09:50:36 -08:00
Martin Atkins
5abd519bef engine/planning: Send null ProviderMeta to providers
The RPC-based provider client panics if it isn't given a non-nil value for
ProviderMeta. We aren't yet ready to send a "real" ProviderMeta value, but
for now we'll just stub it out as a null value so that we have just enough
to get through the provider client code without crashing.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-01-16 09:50:36 -08:00
Martin Atkins
1eb43a6d7e engine/planning: Don't panic if provider configuration fails
The code which tries to ensure that provider clients get closed when they
are no longer needed was not taking into account that a provider client
might not have actually been started at all, due to an error.

It's debatable whether we ought to start this background goroutine in that
case at all, but this is an intentionally-minimal change for now until we
can take the time to think harder about how the call to
reportProviderInstanceClosed should work (and whether it should happen at
all) in that case. This change ensures that it'll still happen in the
same way as it did before.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-01-16 09:50:36 -08:00
Martin Atkins
1792e85e0b configgraph: ResourceInstance.Value should use grapheval.Once
In e879e9060f I introduced the manually-written memoization that was
previously here, as a quick fix for a problem I noticed while working on
something else.

However, using sync.Mutex directly here is not correct because it makes it
possible for this function to deadlock if used incorrectly elsewhere in the
system. The "grapheval" utilities are there to avoid exactly that by making
a call fail immediately with an error if a self-dependency problem arises.

Therefore this will now use grapheval.Once to better encapsulate the
memoization. This both ensures that we cooperate well with the rest of the
system using grapheval and requires less boilerplate inside the Value
method because grapheval.Once is already tailored for exactly this sort of
memoization.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-01-16 07:45:10 -08:00
Martin Atkins
d8b057b064 configs: Skip provider ref validation when modules fail to load
We previously already did some partial skipping of provider reference
validation when there are modules in the tree that failed to load, but we
were still running the main logic that checks whether the providers passed
between module boundaries are consistent.

Because that validation involves checking consistency between different
modules it will tend to generate spurious errors when run against a
partially-loaded module tree. Therefore we must also skip the other
validation steps whenever at least one module failed to load, so that the
reported diagnostics will only describe the problem loading the module and
not produce additional misleading reports describing downstream problems
caused by a module's content being incomplete due to those errors.

This one is kinda awkward to write a test for because it's a very specific
interaction that seems unlikely to arise again, but just to have _some_
representation of this historical problem I wrote a simple test that
intentionally makes one module fail to load and then tests that the result
only contains the diagnostic related to that intentional failure. Before
this fix that test would fail because of the spurious additional errors
produced by the functions we're now skipping.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-01-16 07:43:32 -08:00
Andrei Ciobanu
6d2c5b2100 Render write-only attributes after rendered all of the other attributes (#3667)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-01-16 09:46:54 +02:00
Andrei Ciobanu
5c38e89361 Remove deferral capability leftover (#3676)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-01-16 09:30:37 +02:00
Andrei Ciobanu
66983273e5 Key provider decoding moved from gohcl to hcl/v2 (#3654)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
Co-authored-by: Christian Mesh <christianmesh1@gmail.com>
2026-01-15 17:51:16 +02:00
baa-ableton
e1771c1f95 Module Expansion Transformer now skips creating edges for check related nodes (#3582)
Signed-off-by: Babur Ayanlar <babur.ayanlar@ableton.com>
Signed-off-by: baa-ableton <110462357+baa-ableton@users.noreply.github.com>
Co-authored-by: Martin Atkins <mart@degeneration.co.uk>
2026-01-11 19:14:47 -03:00
James Humphries
16f6b2d119 Handle ignoring computed fields in ignore_changes blocks for testing (#3646)
Signed-off-by: James Humphries <james@james-humphries.co.uk>
2026-01-08 10:51:40 +00:00
Andy Hay
2c35bb8d19 cleanup: remove stale FIXME in tf provider (#3625)
Signed-off-by: Andrew Hay <andrew.hay@benchmarkanalytics.com>
2026-01-05 13:09:50 -05:00
Larry Bordowitz
9b2d29852b lint: reintroduce ST1012 static check
Signed-off-by: Larry Bordowitz <laurence.bordowitz@gmail.com>
2026-01-05 11:54:37 -06:00
James Humphries
56b63795af Fix Http Backend failing to unlock state on Ctrl+C during apply (#3637)
Signed-off-by: James Humphries <james@james-humphries.co.uk>
2026-01-05 07:27:10 -05:00
Gajendra Gouda
014c999360 azure backend: resolve OIDC token dynamically to support ADO refresh (#3594)
Signed-off-by: gajjuu <gajendragouda254@gmail.com>
Signed-off-by: Gajendra Gouda <gajendragouda254@gmail.com>
2026-01-05 07:24:03 -05:00
Andrei Ciobanu
132f7e597a Do not make use of the GenerateConfigPath during validate (#3616)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2025-12-22 15:42:55 +02:00
Christian Mesh
feebfb6ab0 Fix serialization error in tofu apply when using cloud.State (#3611)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
Co-authored-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2025-12-19 06:58:20 -05:00
Martin Atkins
4f99815163 addrs: Target is a fmt.Stringer
We have some test code that includes *addrs.Target values in fmt calls with
the %s and %q verbs, but that type was not actually a fmt.Stringer before.

Go 1.26 is introducing some new checks that cause those uses to cause
failures when building those tests. We could potentially change the tests
to produce the string representation in a different way, but we typically
expect our address types to be "stringable" in this way, so instead we'll
just make Target be a fmt.Stringer, delegating to the String method of
the underlying addrs.Targetable implementation. The addrs.Targetable
interface requires a String method, so all implementations are guaranteed
to support this.

Note that we're not actually using Go 1.26 yet at the time of this commit,
but this is an early fix to make the upgrade easier later. I verified this
using go1.26rc1.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-12-18 10:59:03 -08:00
Andrei Ciobanu
e8d1bb6882 Small tweaks on the guidelines and the scripts for testing the azure backend (#3603)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2025-12-18 08:58:33 +02:00
Christian Mesh
a3fe39ff33 Remove global schema cache and clean up tofu schema/contextPlugins (#3589)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Co-authored-by: Martin Atkins <mart@degeneration.co.uk>
2025-12-17 09:49:39 -05:00
Martin Atkins
4f09b06624 providers: Remove explicit handling of "deferred" signal from providers
This removes most of the code previously added in 491969d29d, because we
since learned that the hashicorp/helm provider signals deferral when any
unknown values are present in provider configuration even though in
practice it can sometimes successfully plan changes in spite of those
unknown values.

That therefore made the hashicorp/helm provider behavior worse under this
change than it was before, returning an error when no error was actually
warranted.

The ephemeral resources implementation landed later and was also
interacting with this change, and so this isn't a line-for-line revert of
the original change but still removes everything that was added in support
of handling provider deferral signals so that we'll be able to start fresh
with this later if we find a better way to handle it.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-12-16 13:09:32 -08:00
Ilia Gogotchuri
1eacb9a046 Retaining resources during destruction - New flag -suppress-forget-errors (#3588)
Signed-off-by: Ilia Gogotchuri <ilia.gogotchuri0@gmail.com>
2025-12-16 15:41:03 +04:00
Christian Mesh
0256de5c4d Consolidate provider resource mocking and overrides (#3547)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2025-12-15 08:52:10 -05:00
Martin Atkins
6a8e62d4fa engine/planning: Minimal building of execution graph
This is a _very_ early, minimal plumbing of the execution graph builder
into the experimental planning engine.

The goal here is mainly just to prove the idea that the planning engine can
build execution graphs using the execgraph.Builder API we currently have.
This implementation is not complete yet, and also we are expecting to
rework the structure of the planning engine later on anyway so this initial
work focuses on just plumbing it in to what we had as straightforwardly
as possible.

This is enough to get a serialized form of _an_ execution graph included
in the generated plan, though since we don't have the apply engine
implemented we don't actually use it for anything yet.

In subsequent commits we'll continue building out the graph-building logic
and then arrange for the apply phase to unmarshal the saved execution graph
and attempt to execute it, so we can hopefully see a minimal version of all
of this working end-to-end for the first time. But for now, this was mainly
just a proof-of-concept of building an execution graph and capturing it
into its temporary home in the plans.Plan model.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-12-12 07:03:52 -08:00
Martin Atkins
697f9d1a16 plans: Minimal handling of new-style execution graphs
During the "walking skeleton" phase of our work on the new planning engine
we're intentionally changing other subsystems like the CLI layer as little
as possible and just wiring things together as straightforwardly as
possible so we can find gaps in our new architectural model before we get
too invested in the current experimental shape of it.

With that in mind, this slightly extends the plans.Plan type and its
associated protobuf serialization so that we'll be able to get an opaque
representation of the new runtime's "execution graph" concept from plan
to apply while the CLI layer is still using the traditional plan models.

This is probably not how we'll deal with this in the long run, but it's
intended to be something we can tear back out relatively easily if we
decide either to abandon this "execution graph" idea altogether or once
we reach the point of implementing a new plan model that better suits the
new architecture.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-12-12 07:03:52 -08:00
Martin Atkins
f36fd65dbd states: SyncState.ResourceInstanceObjectFull tolerate missing resource
This was previously dealing okay with the case where a resource doesn't
have the requested instance, but was not handling the situation where the
resource doesn't exist at all yet.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-12-12 07:03:52 -08:00
Martin Atkins
e879e9060f configgraph: Only ask ResourceInstanceGlue once for each value
Most of what we interact with in configgraph is other parts of the
evaluator that automatically get memoized by patterns like OnceValuer, but
the value for a resource instance is always provided by something outside
of the evaluator that won't typically be able to use those mechanisms, and
so the evaluator's ResourceInstance.Value implementation will now provide
memoization on behalf of that external component, to ensure that we end
up with only one value for each resource instance regardless of how that
external component behaves.

In the case of the current planning phase, in particular this means that
we'll now only try to plan each resource instance once, whereas before
we would ask it to make a separate plan for each call to Value.

For now this is just retrofitted in an minimally-invasive way as part of
our "walking skeleton" phase where we're just trying to wire the existing
parts together end-to-end and then decide at the end whether we want to
refactor things more. If this need for general-purpose memoization ends
up appearing in other places too then maybe we'll choose to structure this
a little differently.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-12-12 07:03:52 -08:00
Martin Atkins
97ca07d05c execgraph: ResourceInstanceResultRef type alias
ResultRef[*states.ResourceInstanceObjectFull] is our current canonical
representation of the "final result" of applying changes to a resource
instance, and so it is going to appear a bunch in the plan and apply
engines.

The generic type is clunky to read and write though, so for this one in
particular we'll offer a more concise type alias that we can use for parts
of the API that are representing results from applying.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-12-12 07:03:52 -08:00
Ilia Gogotchuri
ce5944085f Retaining resource during destruction - action and reason marshalling extension (#3569)
Signed-off-by: Ilia Gogotchuri <ilia.gogotchuri0@gmail.com>
2025-12-12 15:16:54 +04:00
Andrei Ciobanu
14633aaf76 Use root context when evaluating import.id expressions (#3567)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2025-12-10 17:54:18 +02:00