Commit Graph

32946 Commits

Author SHA1 Message Date
Martin Atkins
2fda655ddf tofu: Warn if object literal includes unused attribute for input variable
We intentionally allow assigning object types with a superset of the
attributes included in an input variable's object type constraints because
it makes it possible to assign a whole object for which only some of the
attributes are relevant for one input variable but a different subset might
be relevant when the object value is used in a different part of the
configuration.

However, when the variable is defined using an object literal expression
there is no possible way an unexpected attribute could be useful in a
different part of the configuration, and so that's very very likely to be
a mistake rather than intentional. Therefore we'll generate a "linter-like"
warning in that case to help the author notice their mistake without
introducing any new "strict-mode" language features, or other complexity
that would be harder to maintain and evolve over time.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-09-16 15:19:46 -07:00
Diógenes Fernandes
167fd0d263 fix internal/configs/ on Windows (#3276)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-09-16 16:14:31 -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
9b14212207 fix: internal/getprovider tests on Windows (#3275)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-09-16 15:29:31 -03:00
Diógenes Fernandes
f5ef40c37c fix: TestEnsureProviders using the wrong line breaks and PackageDir separator (#3273)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-09-16 13:27:35 -03:00
Diógenes Fernandes
d280ab1d6b fix: TestExecutable on Windows - expected error message is wrong (#3272)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-09-16 13:27:18 -03:00
Martin Atkins
8b459587ca go.mod: go get github.com/hashicorp/go-getter@v1.8.0
This is the first version of go-getter that uses AWS SDK for Go v2, instead
of the now-obsolete SDK v1. This means that we no longer have an indirect
dependency on the obsolete SDK version, and so should generate less noise
for security scanners that are configured to check for unmaintained
dependencies.

This does unfortunately also force upgrading some of the AWS SDK v2
dependencies, which potentially affects the "s3" backend too. This is the
typical risk of having all of these external integrations linked
directly into our executables, but most of these are just minor upgrades
that we likely would've adopted in the near future anyway.

The newer version of go-getter also uses newer versions of some of its
other dependencies, but we were already on newer versions of most of them
anyway and so the main effect here is just to drop the older versions from
our go.sum file now that they are no longer included in the module version
selection process.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-09-16 09:08:30 -07: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
Diógenes Fernandes
e1dd6c3625 Normalize paths at internal/lang/funcs tests (#3223)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-09-16 09:17:02 -03:00
Larry Bordowitz
0090e8a18c Add new configuration to AzureRM Backend (#3251)
Signed-off-by: Larry Bordowitz <laurence.bordowitz@gmail.com>
2025-09-15 19:22:17 +01: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
79e5070b47 CHANGELOG: New entry for opentofu/opentofu#3256
Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-09-10 11:45:38 -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
57057aef27 Add docs for all ephemeral constructs (#3209)
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>
Co-authored-by: Diógenes Fernandes <diofeher@opentofu.org>
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
cbe16d3a5d Forbid usage of tofu.applying during static eval
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
Christian Mesh
19eed53765 Update funcs package to properly handle ephemeral values (#3168)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2025-09-10 07:45:23 -04:00
Christian Mesh
60b268200c Add ephemeralasnull() function (#3154)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Co-authored-by: Martin Atkins <mart@degeneration.co.uk>
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
db39f00583 Fix the ephemeral resources diagnostics block range (#3136)
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
Martin Atkins
528b778363 website: ORAS v1.3 variant of provider OCI mirror construction
ORAS v1.3.0 introduces some new features that allow directly building an
index manifest in the form that OpenTofu expects, so it's no longer
necessary to edit that index manifest manually.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-09-09 13:22:48 -07:00
Martin Atkins
b54e9af291 lang/marks: Additional unit test for diagnostic generation from expr
The handling of deprecation marks is currently tested mainly in a context
test (i.e. integration test) over in package tofu, but it's nice to also
have some nearby unit test coverage and so this is an initial step in that
direction which we could choose to extend in later commits.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-09-09 10:07:29 -07:00
Martin Atkins
e6955dd824 lang/marks: Use lower-overhead cty functions for marks
In the previous commit we upgraded to cty v1.17.0, which already gave us
some performance improvements for functions like UnmarkDeepWithPaths.

However, this release also includes some new functions that allow more
surgical work with marks, and so we can get some additional gains by using
those in the codepaths related to deprecation tracking.

In particular, using WrangleMarksDeep instead of UnmarkDeepWithPaths means
that we can tell cty that we only want to remove the deprecation-related
marks, and so when given a value that contains only non-deprecation-related
marks it can avoid constructing a new cty.Value altogether, and instead
just return the one that was given. In the case where there _are_
deprecation-related marks, it will rebuild only the parts of the data
structure that lead to those marks. Deprecation-related marks are rare in
practice, so this should be a relatively good payoff.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-09-09 10:07:29 -07:00
Martin Atkins
a66892a9da go.mod: go get github.com/zclconf/go-cty@v1.17.0
This release includes various performance improvents to the marks-related
functionality, which is beneficial to OpenTofu because we've been making
increasingly more use of marks for new use-cases lately.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-09-09 10:07:29 -07: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
Diógenes Fernandes
dddab519ce statemgr: Do not read the state file before acquiring a lock (#3240)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-09-05 16:44:07 -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
Diógenes Fernandes
a88a1f004e Normalize HCL config paths in TestComplianceBinary/* tests on Windows (#3222)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-09-04 13:59:50 -03:00
Ilia Gogotchuri
13d8671db8 Rename the interface graphNodeExpandsInstances (#3237)
Signed-off-by: Ilia Gogotchuri <ilia.gogotchuri0@gmail.com>
2025-09-04 20:19:20 +04:00
Christian Mesh
b66d7a717f Upgrade github.com/go-viper/mapstructure/v2 to v2.4.0 (#3229)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2025-09-04 13:20:04 +01: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
Larry Bordowitz
63e8845ad9 Refactor the azurerm backend (#3034)
Signed-off-by: Larry Bordowitz <laurence.bordowitz@gmail.com>
2025-09-03 11:06:11 -04: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
Martin Atkins
c7afcdf9b4 tracing: Don't panic on OpenTelemetry errors (#3235)
Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-09-03 07:37:45 -04:00
Diógenes Fernandes
35a3100cfe Fix http test server errors on TestBackendConfig_Authentication by removing usage of os.Clearenv (#3221)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-09-02 16:15:30 -03:00
Diógenes Fernandes
2894e494af Normalize line breaks in .tmpl files (#3232)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-09-02 16:08:00 -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
836f6b7d20 Normalize paths in TestParserLoadConfigDirWithTests on Windows (#3226)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-09-02 16:06:22 -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