Commit Graph

840 Commits

Author SHA1 Message Date
Andrei Ciobanu
1239e21c04 Remove unused hcl tags (#3391)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2025-10-20 10:49:08 +03:00
Andrei Ciobanu
4f57c826f0 Add download_retry_count for direct and network_mirror in CLI configuration (#3368)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2025-10-18 11:42:25 +03:00
Andrei Ciobanu
ca3c9f7388 Extract TF_PROVIDER_DOWNLOAD_RETRY env var from the getproviders package (#3338)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2025-10-13 10:00:19 +03:00
Martin Atkins
cbfc28472d go.mod: Upgrade various golang.org/x/* dependencies
The Go team uses automation to generate unnecessary version bumps across
all of these that make it impossible to upgrade them individually because
they all mutually depend on the latest versions of each other, so
unfortunately we have to accept the risk of updating all of these at once
in order to update any one of them.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-10-10 08:23:54 -07:00
Martin Atkins
e74bf2d0a1 go.mod: Use the new "tool" directive
Previously the Go toolchain had no explicit support for "tools" and so we
used the typical Go community workaround of adding "tools.go" files (two,
for some reason) that existed only to trick the Go toolchain into
considering the tools as dependencies we could track in go.mod.

Go 1.24 introduced explicit support for tracking tools as part of go.mod,
and the ability to run those using "go tool" instead of "go run", and so
this commit switches us over to using that strategy for everything we were
previously managing in tools.go.

There are some intentional exceptions here:

- The protobuf-compile script can't use "go tool" or "go run" because the
  tools in question are run only indirectly through protoc. However, we
  do still use the "tool" directive in go.mod to tell the Go toolchain that
  we depend on those tools, so that it'll track which versions we are
  currently using as part of go.mod.
- Our golangci-lint Makefile target uses "go run" to run a specific
  version of golangci-lint. We _intentionally_ don't consider that tool
  to be a direct dependency of OpenTofu because it has a lot of indirect
  dependencies that would pollute our go.mod file. Therefore that continues
  to use "go run" after this commit.
- Both of our tools.go files previously referred to
  github.com/nishanths/exhaustive , but nothing actually appears to be
  using that tool in the current OpenTofu tree, so it's no longer a
  dependency after this commit.

All of the dependencies we have _only_ for tools are now classified as
"indirect" in the go.mod file. This is the default behavior of the Go
toolchain and appears to be motivated by making it clearer that these
modules do not contribute anything to the runtime behavior of OpenTofu.
This also corrected a historical oddity in our go.mod where for some reason
the "indirect" dependencies had been split across two different "require"
directives; they are now all grouped together in a single directive.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-10-10 07:06:56 -03:00
Martin Atkins
6e0a909df2 Remove direct uses of golang.org/x/exp
We were previously using this module to access the then-experimental
"slices" package, but equivalent functionality is now available in a
standard library package so we no longer need to use the experimental
version.

This remains as an indirect dependency just because some of the tools we
use depend on it.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-10-09 15:23:05 -07:00
Christian Mesh
bbf7b1254d Document -force-copy option in -migrate-state error message
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2025-10-07 08:36:30 -04:00
Diógenes Fernandes
e5e9bcd163 fix TestApply_plan_backup test on Windows by using garbage collection (#3320)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-09-30 15:49:55 -03:00
Andrei Ciobanu
7ef6251591 Plan now renders write-only attributes that require replace (#3296)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2025-09-22 17:15:20 +03:00
James Humphries
1e8ccb8d96 fix: Prevent nil panic in marshalProviderConfigs when inSingleModuleMode (#3294)
Signed-off-by: James Humphries <james@james-humphries.co.uk>
2025-09-22 13:40:48 +01:00
Andrei Ciobanu
cf971eb3b6 Rework the way ephemeral variables are used when given on tofu apply command (#3192)
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>
2025-09-22 09:31:19 +03:00
Diógenes Fernandes
767dd7a2fa fix: DirFromModule related tests on Windows (#3289)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-09-20 15:51:29 -03:00
Diógenes Fernandes
197135b4af fix internal/command tests by triggering garbage collection (#3282)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-09-17 09:06:57 -03:00
Diógenes Fernandes
3a8506b14e fix: TestPlan_generatedConfigPath on Windows by standardizing line breaks (#3274)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-09-16 16:11:52 -03:00
Diógenes Fernandes
189c4535f1 Using forward slashes in PackageDir to fix providercache tests in Windows (#3233)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-09-16 09:38:04 -03:00
Martin Atkins
5fa35c5601 backend+command: Alias names for backend types
This introduces the concept of "backend aliases", which are alternative
names that can be used to refer to a given backend.

Each backend type has one canonical name and zero or more alias names. The
"backend" block in the root module can specify either a canonical backend
type or an alias, but internally OpenTofu will always track the backend
type using its canonical name.

In particular, the following are all true when the configuration specifies
an alias instead of a canonical backend type:
- The "tofu init" output includes a brief extra message saying which
  backend type OpenTofu actually used, because that is the name that we'd
  prioritize in our documentation and so an operator can use the canonical
  type to find the relevant docs when needed.
- The .terraform/terraform.tfstate file that tracks the working directory's
  currently-initialized backend settings always uses the canonical backend
  type, and so it's possible to freely switch between aliases and canonical
  without "tofu init" thinking that a state migration might be needed.
- Plan files similarly use the canonical backend type to track which
  backend was active when the plan was created, which doesn't have any
  significant user-facing purpose, but is consistent with the previous
  point since the settings in the plan file effectively substitute for
  the .terraform/terraform.tfstate file when applying a saved plan.
- The terraform_remote_state data source in the provider
  terraform.io/builtin/terraform accepts both canonical and alias in its
  backend type argument, treating both as equivalent for the purpose of
  fetching the state snapshot for the configured workspace.

The primary motivation for this new facility is to allow the planned
"oracle_oci" backend to have an alias "oci" to allow writing configurations
that are cross-compatible with HashiCorp Terraform, since that software
has chosen to have unqualified OCI mean Oracle's system, whereas OpenTofu
has previously established that unqualified OCI means "Open Container
Initiative" in our ecosystem.

In particular, this design makes it possible in principle to bring an
existing Terraform configuration specifying backend "oci" over to OpenTofu
without modifications, and then to optionally switch it to specifying
backend "oracle-oci" at a later time without a spurious prompt to migrate
state snapshots to the same physical location where they are already
stored.

This commit doesn't actually introduce any aliases and therefore doesn't
have any tests for the new mechanism because our backend system uses a
global table that isn't friendly to mocking for testing purposes. I've
tested this manually using a placeholder alias to have confidence that it
works, and I expect that a subsequent commit introducing the new
"oracle_oci" backend will also introduce its "oci" alias and will include
tests that cover use of the alias and migration from the alias to the
canonical name and vice-versa.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-09-11 11:33:53 -07:00
Martin Atkins
2d2b08517e cliconfig: Registry protocol retry count and timeout settings
These were previously settable only via environment variables. These are
now handled as part of CLI Configuration and so also settable in a new
"registry_protocols" block in a CLI configuration file, with the
environment variables now treated as if they are an additional virtual
configuration file containing the corresponding settings.

This handles our settings in our modern style where package cliconfig is
responsible for deciding the configuration and then package main reacts
to that configuration without being aware of how it is decided.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-09-10 11:45:38 -07:00
Diógenes Fernandes
e76a772102 fix: ephemeral end-to-end tests on Windows (#3259)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-09-10 12:07:24 -03:00
Christian Mesh
c8b58e949b Address review comments
Co-authored-by: James Humphries <James@james-humphries.co.uk>
Co-authored-by: Ilia Gogotchuri <ilia.gogotchuri0@gmail.com>
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2025-09-10 07:45:23 -04:00
Andrei Ciobanu
1bab9aff46 Ephemeral todos handling (#3177)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2025-09-10 07:45:23 -04:00
Andrei Ciobanu
ccfeb83889 Renderer keys validation - remove the else branch since does not make sense anymore (#3176)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2025-09-10 07:45:23 -04:00
Andrei Ciobanu
7f76707dd0 Ephemeral write only attributes (#3171)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2025-09-10 07:45:23 -04:00
Christian Mesh
6437bfe01f Add tofu.applying (and terraform.applying) (#3170)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2025-09-10 07:45:23 -04:00
Christian Mesh
4ad9dfa716 Address ephemeralasnull comments/TODOs (#3169)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2025-09-10 07:45:23 -04:00
Andrei Ciobanu
b5d414331f Ephemeral outputs (#3123)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2025-09-10 07:45:23 -04:00
Andrei Ciobanu
013097b631 Ephemeral variables (#3108)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2025-09-10 07:45:23 -04:00
Diógenes Fernandes
e8eeb1334c Adapt TestInit hashes to work on Windows (#3208)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-09-09 11:59:40 -03:00
Diógenes Fernandes
22910f2b01 Adapt statelocker usage to Windows (#3206)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-09-06 10:47:17 -03:00
Christian Mesh
fd4e426a12 Fix test crash when using deprecated outputs in the root module (#3249)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2025-09-05 14:41:32 -04:00
Diógenes Fernandes
c94c96864c Show a change reason on enabled meta-argument when deleting (#3248)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-09-05 14:38:28 -03:00
Larry Bordowitz
45e379b4be Remove unused CLI config fields
Signed-off-by: Larry Bordowitz <laurence.bordowitz@gmail.com>
2025-09-03 14:06:36 -07:00
Diógenes Fernandes
720961605d Replace AWS with local provider to fix end-to-end test on darwin_amd64 (#3224)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-09-03 09:04:12 -03:00
Diógenes Fernandes
07a34d8e54 Close the file handlers in TestWorkspace_deleteWithState after use (#3230)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-09-02 16:07:35 -03:00
Diógenes Fernandes
c2351ec8d9 Normalize paths in TestNewDiagnostic test (#3216)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-09-02 16:06:59 -03:00
Diógenes Fernandes
32c93ed431 Fix TestShow* error messages on Windows tests (#3231)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-09-02 16:06:38 -03:00
Diógenes Fernandes
988c595d5a Normalize paths in TestTest_* on Windows (#3228)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-09-02 16:05:39 -03:00
Ilia Gogotchuri
2c68afe753 CLI import target validation for incorrect for_each keys (#3106)
Signed-off-by: Ilia Gogotchuri <ilia.gogotchuri0@gmail.com>
2025-09-02 13:21:19 +04:00
Diógenes Fernandes
1e48db34a4 fix missing TestConsole* tests on Windows (#3213)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-08-29 14:32:33 -03:00
Diógenes Fernandes
91f7df965f Fix internal/command/validate_test.go: TestValidate_json* (#3202)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-08-29 14:16:47 -03:00
Diógenes Fernandes
1099db8569 fix TestJSON* tests on Windows (#3207)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-08-29 12:41:21 -03:00
Diógenes Fernandes
4ebcf025c6 fix TestConsole* tests on Windows (#3205)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-08-28 20:01:11 -03:00
Diógenes Fernandes
4c2b1df36e fix TestApply* and TestInit* on Windows (#3203)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-08-28 19:55:45 -03:00
Diógenes Fernandes
fda6df4974 fix TestMeta* on Windows (#3201)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-08-28 12:19:00 -03:00
Diógenes Fernandes
7c3e3a3e09 fix internal/command/cliconfig tests on Windows (#3196)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-08-27 18:56:50 -03:00
Martin Atkins
15272f8672 plan diff: summarize the current -> planned notation
The human-oriented plan output includes a short summary of the meaning of
all of the different "icons" used to describe different kinds of change,
but nothing was previously describing how OpenTofu uses "->" to describe
the transition between current and planned values for update in-place, "~".

We'll now include a concise note about that as part of the icon summary,
keeping things still relatively compact but nonetheless giving something
to refer to if a reader is unsure about the meaning of this notation.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-08-26 11:37:44 -07:00
Diógenes Fernandes
dfc1a4e948 feat: allow calling functions from unconfigured providers when no resources are referenced (#3118)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
Signed-off-by: Diógenes Fernandes <diofeher@gmail.com>
Co-authored-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2025-08-22 14:50:17 -03:00
Diógenes Fernandes
11d416edf9 add for_each attribute to the mock_provider block (#3087)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-08-18 10:36:04 -03:00
James Humphries
c5fd93482a Fix crash in unmarkDeepWithPathsDeprecated (#3105)
Signed-off-by: James Humphries <james@james-humphries.co.uk>
Signed-off-by: James Humphries <James@james-humphries.co.uk>
Co-authored-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2025-08-06 15:40:19 +01:00
Andrei Ciobanu
a6c296ddb6 Make ephemeral workflow e2e test to run correctly on windows too - second attempt (#3097)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2025-08-04 18:24:47 +03:00
Andrei Ciobanu
a9a7012396 Adjust the ephemeral workflow e2e test to run correctly on windows too (#3096)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2025-08-04 17:33:28 +03:00