Commit Graph

928 Commits

Author SHA1 Message Date
Martin Atkins
8823f1f17b temp enable GODEBUG winsymlink to see what breaks 2026-04-23 16:34:02 -07:00
Martin Atkins
afdfaf390d Warn when relying on non-default GODEBUG values
"GODEBUG" is a mechanism that the Go runtime forces on OpenTofu that allows
dynamic changes to various nuances of Go standard library behavior.

We cannot control when GODEBUG workarounds are added and removed from Go,
so if someone chooses to rely on them then they are likely to get broken
by a later release of OpenTofu that uses a newer version of Go. Therefore
we'd like anyone relying on these to tell us so we can try to find a more
sustainable solution to their problem early on while the workaround is
still available to them.

We also occasionally force certain GODEBUG workarounds on by default in our
official builds in anticipation of breakage caused by upstream Go changes.
In that case we'd still like to know if anyone is relying on them so that
we can remove those workarounds in a future release, but we'd prefer to
get the reports about it in an issue or discussion we'd already created
for that purpose.

This therefore introduces warning diagnostics any time something in the
"init", "plan", or "apply" commands relies on non-default GODEBUG settings.
For ones we enabled intentionally we provide a specific URL to report usage
as part of the diagnostic message, but we also have a generic message for
any GODEBUG settings the user chose to enable for themselves for reasons
we probably don't know about yet but would like to learn more about.

This is included in only that subset of commands as a compromise because
those are the commands most likely to interact with Go library features
that are affected by these workarounds -- they most commonly affect
functionality related to networking, TLS, etc -- and additional diagnostics
in these locations should not to cause breakage for anyone consuming the
machine-readable output, but there are other commands where additional
diagnostics are more likely to cause problems.

Unfortunately it isn't really possible to unit-test this because it relies
directly on information reported by the Go metrics system and there's no
facility to produce fake metrics for testing. However, Go 1.26 (which we're
currently using) there is a GODEBUG setting "netedns0=0" which causes a
warning any time OpenTofu makes a DNS request, so I've tested this manually
by running "tofu init" with that workaround enabled in a configuration that
depends on at least one provider (causing DNS lookups for the provider
registry) and seen it generate the expected warning message referring to
"netedns0".

These new warnings replace our previous quieter messages about this in
the TF_LOG=warn output, because those were only useful in situations where
GODEBUG was causing a problem that led to someone opening a bug report, but
we actually want to know of situations where GODEBUG was needed in order
for OpenTofu to _succeed_ and so for that we need more prominent messages
to let the operator know there's something they ought to report to us even
though there wasn't an error.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-04-22 17:08:25 -07:00
krishna sindhur
5b5a0972d0 Failed to load backend configuration (#3961)
Signed-off-by: krishna sindhur <krishna.sindhur@harness.io>
2026-04-20 11:04:28 +03:00
Diógenes Fernandes
2c7cd8546c fix: showSensitive working for provisioners output (#3931)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2026-04-15 09:39:53 -03:00
Martin Atkins
bea94265f3 views: TestStateViews non-hardcoded "terraform_version"
The "terraform_version" property of the JSON state format (intentionally
misnamed for backward-compatibility with our predecessor) changes each time
we make a new release, so we'll compare it with the currently-expected
version number instead of with a hard-coded value.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-04-08 14:53:40 -07:00
Andrei Ciobanu
ce59943d99 Remove Ui from the Meta structure (#4000)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Co-authored-by: Christian Mesh <christianmesh1@gmail.com>
2026-04-07 13:38:46 -04:00
Christian Mesh
505f87900a Deprecated resource blocks attrs (#3973)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
Co-authored-by: Martin Atkins <mart@degeneration.co.uk>
Co-authored-by: Andrei Ciobanu <andreic9203@gmail.com>
Co-authored-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-04-07 10:30:43 -04:00
Andrei Ciobanu
030e34725c Migrate cloud and remote backends to the views package (#3982)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-04-07 10:15:05 +03:00
ogormans-deptstack
c1b7229bbd statemgr: pretty-print local backend state files for readable diffs (#3922)
Signed-off-by: ogormans-deptstack <sean.ogorman@deptagency.com>
Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
Co-authored-by: Martin Atkins <mart@degeneration.co.uk>
2026-04-06 07:25:03 -04:00
Christian Mesh
55ef1669b2 Support const variables in static eval (#3946)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Co-authored-by: Martin Atkins <mart@degeneration.co.uk>
2026-04-02 07:39:54 -04:00
James Humphries
c874a1c8fd Fix flaky TestJsonIntoStream by not comparing elapsed durations between runs
Signed-off-by: James Humphries <james@james-humphries.co.uk>
2026-04-02 07:11:07 -04:00
James Humphries
f81a5fca52 Improve resource identity rendering in plan output and import hooks (#3883)
Signed-off-by: James Humphries <james@james-humphries.co.uk>
2026-04-02 12:08:04 +01:00
James Humphries
c88018bac0 Add resource identity schemas to tofu provider schemas output (#3898)
Signed-off-by: James Humphries <james@james-humphries.co.uk>
2026-04-01 15:50:12 +01:00
James Humphries
317de6d46e Store BeforeIdentity and AfterIdentity and display it in the plan json output (#3779)
Signed-off-by: James Humphries <james@james-humphries.co.uk>
2026-04-01 10:46:38 +01:00
James Humphries
19af81d28e Implement resource identity support (#3671)
Signed-off-by: James Humphries <james@james-humphries.co.uk>
Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
Co-authored-by: Martin Atkins <mart@degeneration.co.uk>
2026-03-31 16:57:21 +01:00
Andrei Ciobanu
b5010cb952 Remove GatherVariables methods (#3962)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-03-31 14:22:31 +03:00
Andrei Ciobanu
b53682ace6 Remove Meta not needed functionality (#3958)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-03-31 10:15:13 +03:00
Andrei Ciobanu
e789a7f63c Remove show diagnostics (#3950)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-03-30 16:00:21 +03:00
Andrei Ciobanu
8689efa1f1 Add backend view and migrate outputs (#3949)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-03-30 15:35:09 +03:00
RoseSecurity
6e2250e050 chore: typo fixes (#3957)
Signed-off-by: RoseSecurity <michael@rosesecurity.dev>
2026-03-27 18:25:56 -03:00
Andrei Ciobanu
440edcd754 Deny ephemeral values in count (#3924)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-03-27 20:24:15 +02:00
Andrei Ciobanu
1b5af7a229 Rework ephemeral resources apply phase (#3897)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-03-27 20:00:13 +02:00
Andrei Ciobanu
866b067c0d Unify patterns across the refactored commands (#3941)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-03-26 17:19:27 +02:00
Andy Brody
dbe023fdf6 Add .tofu/.tofutest.hcl to tofu fmt error message. (#3947)
Signed-off-by: Andy Brody <git@abrody.com>
2026-03-25 16:01:18 -04:00
Andrei Ciobanu
c4b269eb87 Refactor state show command to use View instead of Ui and to use the arguments package (#3865)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-03-23 13:23:41 +02:00
Andy Hay
5179bab7e5 e2etest: strip state_lock messages in TestJsonIntoStream
On Windows, the two sequential plan runs in TestJsonIntoStream have different latencies — the -json-into run is consistently slower and crosses the timer threshold that emits state_lock_acquire, while the -json run does not. This causes a spurious one-line diff between the two outputs.

Strip state_lock_acquire/release lines from both outputs before comparison since these messages are timing-dependent and not relevant to the test's core assertion.
2026-03-20 12:02:46 -07:00
Andy Hay
070698be32 Refactor providers schema command to use views and arguments packages (#3822)
Signed-off-by: Andrew Hay <andrew.hay@benchmarkanalytics.com>
Signed-off-by: Andy Hay <39sumer3939@gmail.com>
Signed-off-by: Andy Hay <andrew.hay@benchmarkanalytics.com>
Co-authored-by: Andrei Ciobanu <andreic9203@gmail.com>
2026-03-20 16:43:20 +02:00
Christian Mesh
0832642188 tofu providers mirror: Add option to trust hashes from a mirror source (#3885)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Co-authored-by: James Humphries <James@james-humphries.co.uk>
Co-authored-by: Martin Atkins <mart@degeneration.co.uk>
2026-03-19 14:00:51 -04:00
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
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
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
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
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
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
Andrei Ciobanu
2ed9550790 Refactor state push command to use View instead of Ui and to use the arguments package (#3842)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-03-09 13:00:30 +02:00
Andrei Ciobanu
aeb3bfe452 Refactor state pull command to use View instead of Ui and to use the arguments package (#3837)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-03-09 12:25:18 +02:00
Andrei Ciobanu
315d028767 Refactor state mv command to use View instead of Ui and to use the arguments package (#3835)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-03-06 15:22:52 +02:00
Andrei Ciobanu
db00cb2f3b Refactor import command to use View instead of Ui and to use the arguments package (#3772)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-03-06 15:11:57 +02:00
Andrei Ciobanu
f9f8b1a258 Use the arguments already configured ViewOptions (#3836)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-03-05 15:33:15 +02:00
Andrei Ciobanu
5fcfb23eb5 Refactor fmt command to use View instead of Ui and to use the arguments package (#3805)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-03-05 14:47:37 +02:00
Andrei Ciobanu
383d6b3595 Refactor version command to use View instead of Ui and to use the arguments package (#3806)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-03-05 14:47:29 +02:00
Andrei Ciobanu
b992aa6582 Refactor taint && untaint commands to use View instead of Ui and to use the arguments package (#3818)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-03-05 09:50:36 +02:00
Andrei Ciobanu
9b389f7b1a Refactor providers lock command to use View instead of Ui and to use the arguments package (#3812)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-03-05 09:49:36 +02:00
Andrei Ciobanu
b3a6820bdf Refactor providers command to use View instead of Ui and to use the arguments package (#3811)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-03-05 09:49:15 +02:00
Andrei Ciobanu
7338f5748b Refactor graph command to use View instead of Ui and to use the arguments package (#3802)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-03-04 15:21:37 +02:00
Andrei Ciobanu
c98d5e22c7 Refactor providers mirror command to use View instead of Ui and to use the arguments package (#3813)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-03-04 15:20:39 +02:00
Andrei Ciobanu
1201c49010 Refactor unlock command to use View instead of Ui and to use the arguments package (#3823)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-03-04 15:20:19 +02:00
Andrei Ciobanu
6cd6a7e320 Refactor state list command to use View instead of Ui and to use the arguments package (#3828)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-03-04 15:20:06 +02:00
Andrei Ciobanu
0ffecc7a14 Refactor all workspace commands to use View instead of Ui (#3770)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-03-03 12:44:56 +02:00
Andrei Ciobanu
d701eecf47 Refactor console command to use View instead of Ui (#3764)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-03-02 18:58:11 +02:00