Commit Graph

33420 Commits

Author SHA1 Message Date
krishna sindhur
6a385c3cbc Read state refactor (#3706)
Signed-off-by: KrishnaSindhur <krishna.sindhur@harness.io>
Signed-off-by: krishna sindhur <krishna.sindhur@harness.io>
2026-03-19 17:03:16 +02:00
Martin Atkins
48af3ba77a go.mod: go get github.com/go-viper/mapstructure/v2@v2.5.0
This is just a routine upgrade. Upstream has added various new features but
all of them require opt-in either by explicit configuration or by using
new field types that were not previously supported at all, so they should
not immediately affect OpenTofu's behavior.

OpenTofu uses this library only in some legacy code that sticks around from
much older versions of its predecessor. Most uses of it were replaced by
HCL-based and cty-based equivalents a long time ago, but it sticks around
in the inline copy of the legacy plugin SDK used by the config decoding
logic from some state storage backends, and in some of the provisioner
configuration handling. These features only use very old, legacy parts of
the mapstructure library that have been preserved for
backward-compatibility.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-03-19 06:33:06 -07:00
Martin Atkins
4b50d746bb go.mod: go get github.com/bmatcuk/doublestar/v4@v4.10.0
This is just a routine upgrade. The only upstream change that could affect
runtime behavior is a new option to disable matching hidden files, but
that's an opt-in so will not affect OpenTofu's behavior.

This library is used only as part of the implementation of the built-in
function "fileset", which returns a set of paths matching a given glob
pattern.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-03-19 06:32:04 -07:00
Martin Atkins
609a1a6305 CHANGELOG: entry for opentofu/opentofu#3300
Because this is work based on an RFC, as usual this links to the RFC
tracking issue instead of to an individual PR since that's a better
overview of all the work behind this change.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-03-18 09:09:50 -07:00
Martin Atkins
5b67329bff website: Documentation for "language" blocks
This repurposes the page that was previously about "terraform" blocks to
now be about "language" blocks instead.

This is the modern way to describe version compatibility constraints for
OpenTofu, though we retain some support for required_versions in
"terraform" blocks as a transitional aid for those who want to write
modules that can work with older versions of OpenTofu.

There were previously additional sections on this page discussing other
settings that can appear in "terraform" blocks, but they were essentially
just links to more detailed documentation elsewhere and so this reduces
all of that to just a single section that acknowledges that this block
type accepts other options and links to the relevant documentation for
each one. This structure matches the reality that "terraform" blocks are
just a dumping ground for a variety of tangentially-related settings, and
that we're intending to gradually replace all of the settings in there
with brand-agnostic alternatives in future releases.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-03-18 09:09:50 -07:00
Martin Atkins
551579f5eb configs: New-style core version constraints, etc
Previously we interpreted a "required_version" argument in a "terraform"
block as if it were specifying an OpenTofu version constraint, when in
reality most modules use this to represent a version constraint for
OpenTofu's predecessor instead.

The primary effect of this commit is to introduce a new top-level block
type called "language" which describes language and implementation
compatibility metadata in a way that intentionally differs from what's used
by OpenTofu's predecessor.

This also causes OpenTofu to ignore the required_version argument unless
it appears in an OpenTofu-specific file with a ".tofu" suffix, and makes
OpenTofu completely ignore the language edition and experimental feature
opt-in options from OpenTofu's predecessor on the assumption that those
could continue to evolve independently of changes in OpenTofu.

We retain support for using required_versions in .tofu files as a bridge
solution for modules that need to remain compatible with OpenTofu versions
prior to v1.12. Module authors should keep following the strategy of
having both a versions.tf and a versions.tofu file for now, and wait until
the OpenTofu v1.11 series is end-of-life before adopting the new "language"
block type.

I also took this opportunity to simplify how we handle these parts of the
configuration, since the OpenTofu project has no immediate plans to use
either multiple language editions or language experiments and so for now
we can reduce our handling of those language features to just enough that
we'd return reasonable error messages if today's OpenTofu is exposed to
a module that was written for a newer version of OpenTofu that extends
these language features. The cross-cutting plumbing for representing the
active experiments for a module is still present so that we can reactivate
it later if we need to, but for now that set will always be empty.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-03-18 09:09:50 -07:00
Martin Atkins
340f8d1fdd go.mod: go get golang.org/x/net@v0.52.0
This is just a routine upgrade. The Go project's ratcheting policy means
that we must also upgrade x/crypto, but that one doesn't have any changes
that are significant to OpenTofu.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-03-18 06:52:01 -07:00
Martin Atkins
bf7060ebb1 go.mod: Update various golang.org/x/* dependencies
Because the Go team always ratchets these all to depend on newer versions
of each other, it's not possible to upgrade these in isolation.

The main goal of this commit is to update all of the modules whose only
significant change is the dependency ratchet, in preparation for performing
more significant upgrades.

Unfortunately because many of these modules depend on x/tools, and x/tools
depends on x/net, there is no way to avoid performing a partial upgrade
of x/net. This is the smallest possible upgrade to that module to satisfy
the dependencies of the others I intend to make a followup commit focused
on x/net to bring it all the way to the latest available version.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-03-18 06:52:01 -07:00
Martin Atkins
5737ebcc01 CHANGELOG: Copyedit in preparation for the v1.12 prerelease period
This rewrites and reorders various entries added to the changelog during
the v1.12 development period to use consistent terminology and phrasing
between similar items and to present the changes in a very subjective
ordering by "relevance".

As usual, "relevance" is pretty loosely defined but the general guideline
is: configuration-related changes, then CLI-related changes, then changes
that affect integrations with other software like providers and backends.
Within each of those categories I went mainly by "vibes" based on my
impression of how much interest there had been in each of the features
or fixes in earlier discussion.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-03-18 06:51:16 -07:00
Martin Atkins
a800d250e5 command: "go fix" on various files we've changed recently anyway
We don't typically just broadly run automatic rewriting tools like "go fix"
across our codebase because that tends to cause annoying and unnecessary
merge conflicts when we're backporting to earlier release branches.

But all of the files in this commit were changed in some non-trivial way
already during the OpenTofu v1.11 development period anyway, and so the
likelyhood we'd be able to successfully backport from them is reduced and
therefore this seems like a good opportunity to do some focused
modernization using "go fix".

My rules for what to include or not are admittedly quite "vibes-based", but
the general idea was:

 - Focusing on files under the "command" directory only, because that's
   already been an area of intentional refactoring during this development
   period.
 - If the existing diff in a file is already significantly larger than
   the changes the fixer proposed to make, or if the fixer is proposing
   to change a line that was already changed in this development period.
 - More willing to include "_test.go" files than non-test files, even if
   they hadn't changed as much already, just because backports from test
   files for bug fixes tend to be entirely new test cases more than they
   are modifications to existing test cases, and so the risk of conflicts
   is lower there.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-03-17 15:25:30 -07:00
Martin Atkins
b2c20bda29 flock: Partially-manual modernization of waitgroup usage
The "go fix" modernizer for using wg.Go instead of explicit wg.Add/wg.Done
only works when the goroutine function has no arguments, so it didn't match
here where this code was still using an old trick to ensure that each
goroutine would capture a different value of "i".

But that old trick isn't needed anymore because modern Go already ensures
that each iteration of the loop has an independent "i", so I made a small
change to remove the argument and just let the closure capture "i" from
the outer loop, and then "go fix" was able to complete the rewrite to
use wg.Go here.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-03-17 15:25:09 -07:00
Martin Atkins
2b85803b7d flock: go fix
This is just the result of running the "go fix" modernizers against this
package.

It seems that there were some lines with trailing whitespace previously,
which also got removed here because "go fix" includes an implicit "go fmt".

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-03-17 15:25:09 -07:00
Martin Atkins
beb4d94d57 encruption/keyprovider/*: go fix
This is the result of running the "go fix" modernizers on the subset of
files under this prefix that were already changed during the v1.12
development period.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-03-17 13:21:06 -07:00
Martin Atkins
139b5cc839 providercache: go fix
This is just the result of running the "go fix" modernizers on the
providercache package.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-03-17 13:20:48 -07:00
Martin Atkins
92d8b4dd7d backend/remote-state/azure: go fix
This is the result of running the "go fix" modernizers on this package,
with no other changes.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-03-17 13:20:32 -07:00
Martin Atkins
a38c1c2298 go fix ./internal/addrs
This is the result of running the "go fix" modernizers against the addrs
package.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-03-17 13:20:13 -07:00
Alex St John
285bedc26e Multi config migration (#3677)
Signed-off-by: Alex St John <alexandros.georgakoudi@gmail.com>
Signed-off-by: Alex St John <33961662+AlexSTJO@users.noreply.github.com>
Co-authored-by: Andrei Ciobanu <andreic9203@gmail.com>
2026-03-17 15:11:44 +00:00
Andrei Ciobanu
57a68260e9 Allow key_provider blocks to reference with raw references other key_provider blocks in JSON format (#3794)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-03-17 16:06:09 +02:00
Martin Atkins
0fe01076e7 go.mod: Upgrade go.opentelemetry.io/* dependencies
This is just a routine upgrade.

The latest version of go.opentelemetry.io/otel/sdk has adopted a newer
version of semconv and so this also updates our traceattrs package to
use the same version, as usual.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-03-17 06:21:24 -07:00
James Humphries
42c144403f fix panic in init -from-module when module source references variables (#3851)
Signed-off-by: James Humphries <james@james-humphries.co.uk>
2026-03-17 09:18:41 +00:00
RameshXT
9eb2083c35 docs: add warning callout for TF_PLUGIN_CACHE_DIR conflict with mirror dirs (#3881)
Signed-off-by: Ramesh XT <rameshkanna841@gmail.com>
Signed-off-by: RameshXT <143485526+RameshXT@users.noreply.github.com>
2026-03-17 09:52:30 +02:00
Babur Ayanlar
7f69c7e1e1 Added new method to enable replacing downstream resources (#3848)
Signed-off-by: Babur Ayanlar <babur.ayanlar@ableton.com>
2026-03-17 09:15:10 +02:00
Martin Atkins
1db4c38ce6 tofu2024: Unit tests for the handling of "enabled" meta-arguments
As with the previous tests added for for_each, this is some basic coverage
under the assumption that the rules for count are not likely to change
so much that it would be arduous to update these tests.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-03-16 10:58:40 -07:00
Martin Atkins
febfa260b2 tofu2024: Unit tests for the handling of "count" meta-arguments
As with the previous tests added for for_each, this is some basic coverage
under the assumption that the rules for count are not likely to change
so much that it would be arduous to update these tests.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-03-16 10:58:40 -07:00
Martin Atkins
29ddba7783 tofu2024: Some extra checks for the range of "count"
The previous implementation was rejecting most out-of-range errors, but
it was not rejecting negative numbers, and it was also generating
misleading error messages in other cases because cty's own error messages
for numeric range are pretty generic.

Now we'll do our own numeric range checks before we attempt to extract
the number into an int variable, so we can return more tailored error
messages and can reject negative numbers properly.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-03-16 10:58:40 -07:00
Martin Atkins
1e3cddd948 tofu2024: Initial unit test for singleton instance selector
This case is not particularly interesting -- it just always produces a
hard-coded result -- but is tested anyway for completeness.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-03-16 10:58:40 -07:00
Martin Atkins
4f0ba5a6cb tofu2024: Initial unit tests for for_each handling
So far we've been pretty light on testing in these new codepaths because
they've been churning quite a lot during our "walking skeleton" phase of
the new runtime development.

But this instance-selector-related code seems relatively self-contained and
settled, so this introduces an initial set of unit tests for the handling
of for_each expressions, primarily just to document what the intended
behavior of the current implementation was and to illustrate that it is
indeed unit-testable in (relative) isolation.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-03-16 10:58:40 -07:00
Martin Atkins
6fc3a03198 tofu2024: Properly handle unknown object-typed values in for_each
The comment here was correct that we can accept unknown values of object
types because the attributes are known as part of the type, but we do still
need to handle that in a special way because we need to produce the result
based only on the type information in this case, without trying to access
the value.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-03-16 10:58:40 -07:00
Martin Atkins
906e35cff1 tofu2024: Do typechecking of for_each even when it's unknown
In earlier work we added some more detailed typechecking rules further
down that can reject incorrectly-typed values even when the value is
unknown, but forgot to remove this early return that made that other code
unreachable whenever the value is unknown.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-03-16 10:58:40 -07:00
Martin Atkins
50b49d98c1 lang/exprs: FlatScopeForTesting
For unit tests of components that don't depend on any particular symbol
table structure, where we just want to test if they are using the provided
scope _at all_, it's helpful to be able to just quickly create a static
symbol table.

This is a reusable helper function for that.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-03-16 10:58:40 -07:00
Andrei Ciobanu
f805983ed4 Fix the simple-provider schema for data-source (#3884)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-03-16 15:25:55 +02:00
Martin Atkins
cba3902c0b rfc: Slight simplification of the "misc settings" RFC
The earlier drafts of this RFC included a special rule for ignoring
required_version declarations across all files in any module that includes
a "language" block. That special case was an adaptation of some complexity
from earlier proposals in this area that was intended for gradual adoption
of the new syntax.

However, with the current form of this proposal that exception doesn't
really serve any useful purpose: any module with a "language" block in it
will be immediately incompatible with OpenTofu v1.11, but we already
included a gradual adoption strategy by having authors continue to use
the old-style required_version pattern until they are ready to require
OpenTofu v1.12 or later.

Therefore we'll now amend the RFC to say that the old and new strategies
are allowed to coexist in the same module and that OpenTofu will check and
enforce them separately, which is an easier rule to explain and also much
easier to implement because it allows checking each declaration
independently rather than having to wait until the full module has loaded
to decide which declarations are relevant.

This also proposes a small heuristic warning to hopefully help authors
notice that they must continue using required_version for any module that
is explicitly intended to support the OpenTofu v1.11 series. This will
complement our documentation to reinforce the recommendation to continue
using the old-style approach until the v1.11 series is no longer supported.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-03-13 08:16:55 -07:00
Christian Mesh
9f307d14b1 Additional hash filter for registry package source (#3873)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2026-03-13 09:53:33 -04:00
Christian Mesh
06bff7f3a3 Utilize new registry platform metadata (#3868)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Co-authored-by: Martin Atkins <mart@degeneration.co.uk>
2026-03-13 06:58:11 -04:00
Martin Atkins
468d66678d states: Separate SyncState method for removing "full" objects
Our new language runtime uses a set of new methods on SyncState to work
with its preferred "full" representation of resource instance objects, but
those are implemented in terms of methods that already existed for the old
runtime's benefit and so we need to deal with some quirks of those existing
methods.

One such quirk is that the operations to write or remove objects also want
to update some resource-level and instance-level metadata as a side-effect,
and we need to carry through that metadata even when we're intending to
completely remove a resource instance object.

To preserve our goal of leaving the existing codepaths untouched for now,
this pushes a little complexity back up into the main caller in the apply
engine, forcing it to call a different method when it knows it has deleted
an object. That new method then only takes the metadata we need and not
an actual resource instance object, so it gels better with the underlying
ModuleState methods it's implemented in terms of.

Hopefully in the long run we'll rethink the state models to not rely on
these hidden side-effects, but that's beyond the scope of our current phase
of work on the new language runtime.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-03-11 07:28:09 -07:00
Martin Atkins
906984d518 go.mod: go get golang.org/x/crypto@v0.48.0
This is just a routine upgrade. It contains a single fix for a panic bug
on invalid arguments to scrypt.Key.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-03-10 09:50:16 -07:00
Andrei Ciobanu
a673617189 Refactor state rm command to use View instead of Ui and to use the arguments package (#3849)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-03-10 17:54:01 +02:00
Martin Atkins
046cf008d4 go.mod: go get golang.org/x/term@v0.40.0
This is just a routine upgrade. There are absolutely no useful changes in
this release, but the Go team routinely just ratchets up the
interdependencies between the golang.org/x/* modules, and this one was
recently unblocked by us upgrading to golang.org/x/sys v0.42.0.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-03-10 08:43:05 -07:00
Martin Atkins
ff2f733b79 go.mod: go get golang.org/x/sys@v0.42.0
This is just a routine upgrade.

Changes to this module are often tricky to review because OpenTofu's
relationship to most code in this module is very indirect, but from
studying the code diff carefully it doesn't seem like any changes here will
negatively impact OpenTofu's behavior.

This changeset includes some improvements to how supported CPU features are
detected on darwin_arm64 which may cause architecture-specific code in
some of our dependencies to perform better by using newer architecture
features, but I've not gone searching for any specific examples of that.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-03-10 08:43:05 -07:00
Andrei Ciobanu
fc9c19eb9a Refactor state replace-provider command to use View instead of Ui and to use the arguments package (#3844)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-03-10 17:01:58 +02:00
Martin Atkins
06bf6c3310 go.mod: go get github.com/opentofu/registry-address/v2@v2.0.0-20260307135325-45f3562374e4
This is just a routine upgrade to the latest available commit, just for
the sake of getting this off our list of available upgrades.

The only change here is from opentofu/registry-address#7, which is purely
a documentation update that doesn't affect the behavior.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-03-10 07:22:01 -07:00
Martin Atkins
c22f9c3523 go.mod: Upgrade various golang.org/x/* dependencies
Go team policy is to ratchet all of these together and so this is just the
usual periodic churn of updating all of the "easy" ones (the ones that
don't affect code that OpenTofu is directly using) to unblock later
upgrades of the ones that might require more intricate review.

All of the direct dependencies upgraded here feature only irrelevant
upgrades such as code modernization or new functionality that OpenTofu does
not currently import.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-03-10 07:21:06 -07:00
Martin Atkins
1498904295 go.mod: go get github.com/ProtonMail/go-crypto@v1.4.0
This also includes an upgrade to github.com/cloudflare/circl@v1.6.3, which
is newer than strictly required by go-crypto but includes the fix for a
security advisory that does not affect OpenTofu but would otherwise cause
false-positive reports because the Go vulnerability database entry for it
is too broad. The goal here is only to reduce false-positive scanner noise
for folks using the forthcoming v1.12.x series.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-03-09 11:59:57 -07:00
Larry Bordowitz
c6a4329aa4 go.mod: Upgrade to Go 1.26.1
Signed-off-by: Larry Bordowitz <laurence.bordowitz@gmail.com>
2026-03-09 13:54:13 -05:00
Christian Mesh
0e26f19aa0 Add notes on how we plan to do the backfill
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2026-03-09 13:10:58 -04:00
Christian Mesh
565220bdd3 Add section on updating pre-existing releases
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2026-03-09 13:10:58 -04:00
Christian Mesh
a9f919bd03 Apply suggestions from code review
Co-authored-by: James Humphries <James@james-humphries.co.uk>
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2026-03-09 13:10:58 -04:00
Christian Mesh
5547090b68 Formatting
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2026-03-09 13:10:58 -04:00
Christian Mesh
0e43055f98 Update provider locking RFC with feedback
Co-Authored-By:  Martin Atkins <mart@degeneration.co.uk>
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2026-03-09 13:10:58 -04:00
Christian Mesh
097be1940e Initial draft of provider registry hashes RFC
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2026-03-09 13:10:58 -04:00