Commit Graph

932 Commits

Author SHA1 Message Date
Daniel Argüelles
4cd02246bb feat: add test for OCI repository handling with 401 Unauthorized response
Signed-off-by: Daniel Argüelles <leinad87@gmail.com>
2026-05-13 08:52:36 -07:00
Martin Atkins
1d3548a0e7 providercache: Don't clobber mismatching cache entries
Prevously OpenTofu's provider installer would try to install a package even
if there was already a directory there which doesn't match the package
contents. That's effective in making us more likely to end up with a
working provider cache directory, but risks clobbering a package directory
that the operator intentionally modified for some reason.

We'll now require that if an existing directory (or symlink to one) is
present at the place where we'd need to put our cache entry then its
contents must already match what we're trying to install, thereby making
this a no-op. If the existing contents don't match then we'll fail with an
error to let the operator decide whether they need to keep something from
their modified directory before deleting it.

In earlier versions of OpenTofu, silently replacing an existing directory
was actually sometimes done intentionally to ensure that the cache would
definitely match the dependency lock file, but we no longer need to do that
because as of OpenTofu v1.12 the provider installer now exits early
(without downloading anything at all) if a matching package is already
present, so we never end up trying to replace a package that was already
present on disk unless it's the case we're now trying to catch as an error
here.

The handling of this is in PackageLocalArchive because the two
network-based location types (HTTP archive and OCI blob archive) work by
first fetching the archive to a temporary local location and then asking
the local archive location to finish the installation.

This is covered by e2etests rather than a unit test because successfully
hitting this error requires both the "providercache" and "getproviders"
packages to cooperate to let execution reach this late step without any
earlier code doing an early exit due to the directory already being
present. The e2etest runs through that entire codepath to make sure we
reach the error message we're expecting to reach.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-05-08 08:35:38 -07:00
Babur Ayanlar
5ddfb11cbc tofu plan: mention that empty plan might be caused by incorrect -target
Signed-off-by: Babur Ayanlar <babur.ayanlar@ableton.com>
2026-04-28 11:40:20 -07:00
Christian Mesh
2cfaa36598 Deprecation diagnostics internal rework (#3996)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Co-authored-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-04-28 07:44:49 -04:00
Andrei Ciobanu
0af2e8d521 UIInput must return when the first SIGINT/SIGTERM signal is received (#4051)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2026-04-27 17:03:57 +03:00
DongJun Lee
c6f06f8f6d fix: prevent panic in tofu login OAuth flow due to channel race (#4016)
Signed-off-by: dongjune8931 <ldj990517@gmail.com>
2026-04-25 10:00:52 -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