Commit Graph

33011 Commits

Author SHA1 Message Date
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
c923b80089 tools: find-dep-upgrades for suggesting an order to upgrade deps
We tend to get scared off from routine dependency upgrades because it's
hard to know where to start when we want to avoid upgrading too many things
at once and thus making it hard for us to understand the impact.

This tool makes a best effort to suggest an order of upgrades that lets us
upgrade one thing at a time when possible, and if not possible then at
least tries to minimize how many things get upgraded at once.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-10-09 16:03:44 -07: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
Martin Atkins
12f6a2fb8e go.mod: go get github.com/hashicorp/go-version@v1.7.0
This is just a routine upgrade, and doesn't change any functionality that
OpenTofu depends on. It includes a potential performance improvement for
comparisons between versions, and implementation of some
irrelevant-to-OpenTofu interfaces from the database/sql/driver package.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-10-09 15:22:43 -07:00
Martin Atkins
29408a9a54 CHANGELOG: Entry for opentofu/opentofu#3354
Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-10-09 13:06:27 -07:00
Martin Atkins
02be03956f go.mod: go get github.com/mattn/go-shellwords@v1.0.12
This upgrade includes some behavior changes that will affect OpenTofu's
handling of the TF_ARG_* environment variables, but in a generally positive
way: the parsing of those is now closer to how Unix shells typically
behave.

Although it's unlikely that this would affect anyone, it is technically a
behavior change that could potentially change the handling of some unusual
patterns such as empty arguments represented as pairs of quotes with
nothing between them.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-10-09 13:06:27 -07:00
Martin Atkins
d60cddd883 go.mod: go get github.com/xanzy/ssh-agent@v0.3.3
This fixes some bugs that could potentially affect Windows users, though
they all appear to be unlikely problems that we've never had any reports
of from OpenTofu users, so this is mostly just a routine upgrade.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-10-09 13:05:59 -07:00
Martin Atkins
32a04dbbb4 go.mod: go get golang.org/x/oauth2@v0.32.0
This is just a routine upgrade. The upstream library contains no relevant
functional changes, just some different implementation details.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-10-09 13:05:22 -07:00
Martin Atkins
f8019f081f go.mod: go get github.com/hashicorp/go-retryablehttp@v0.7.8
This release introduces an optional new backoff policy implementation, but
that is entirely new functionality that no OpenTofu caller uses and so
this should not cause any behavior changes.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-10-09 13:04:39 -07:00
Martin Atkins
c70ead2e86 go.mod: go get github.com/apparentlymart/go-versions@v1.0.3
This patch release includes an improvement to the error messages for
certain syntax errors involving "v" prefixes, which were previously
returning confusing error messages that misdiagnosed the problem.

There are no other behavior changes.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-10-09 13:04:13 -07:00
Martin Atkins
2491c794d8 go.mod: go get golang.org/x/term@v0.36.0
This is a no-changes release that was generated by the Go team's upgrade
bot, which we're adopting here only because some of our other dependencies
require it but I want to upgrade those alone so we're not changing many
things all at once.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-10-09 07:31:57 -07:00
Martin Atkins
15cec171f4 go.mod: go get golang.org/x/sync@v0.17.0
This is an utterly pointless upgrade because it only modifies this module's
go.mod to require Go 1.24 instead of Go 1.23, but I'm upgrading it here
anyway because some of our other pending upgrades require this newer
version and I want to keep each of these upgrade PRs as small as possible.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-10-09 07:31:31 -07:00
Martin Atkins
ec8bd86016 go.mod: Use Go 1.25.2
The 1.25.1 and 1.25.2 patch releases both include various security updates
that don't appear to directly affect OpenTofu, but nonetheless we'll
upgrade in preparation for our forthcoming v1.11.0 release so that these
advisories won't cause false-positives for imprecise security scanners
throughout our v1.11 series.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-10-08 17:42:47 -07:00
Martin Atkins
c57231ed1b go.mod: go get github.com/hashicorp/go-getter@v1.8.2
This includes a fix to a bug introduced in an earlier version of go-getter:
  https://github.com/hashicorp/go-getter/pull/560

We did not actually use an affected version of go-getter in any stable
release yet, and so this change does not require a changelog update for
OpenTofu.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-10-08 17:42:14 -07:00
Martin Atkins
83c22604b9 go.mod: go get golang.org/x/sys@v0.37.0
This is just a routine upgrade, which doesn't cause any significant changes
to OpenTofu's behavior.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-10-08 17:41:55 -07:00
Martin Atkins
b88e966a30 go.mod: go get github.com/hashicorp/go-plugin@v1.7.0
This also upgrades two indirect dependencies, but we have those primarily
because of go-plugin and don't rely on them for any other significant
functionality.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-10-08 17:41:35 -07:00
Martin Atkins
27e6565701 Use the latest protobuf tools and libraries throughout
Previously we were using a mixture of old and new, with our code generation
using the plugin from the old github.com/golang/protobuf library but
our callers using the modern google.golang.org/protobuf . We were also
using pretty ancient version of protoc.

This brings us up to the current latest releases and consistently using
the new Go protobuf library. There have been some notable changes to these
tools in the meantime:

Previously the protoc-gen-go plugin handled grpc by having its own
additional level of Go-specific "plugins" of which the gRPC codegen was
an example.

Now the protobuf generator and the gRPC generator are separate plugins
handled directly by protoc, which means the command line arguments are
a different shape and the gRPC stubs get generated in a separate file
from the main protobuf messages, rather than all being in one .pb.go file
as before.The results are otherwise similar, though.

The grpc codegen now also defaults to requiring that implementations embed
the generated "unimplemented" server, which is an implementation of each
service where the methods just immediately return the "unimplemented"
error. This is not super important for us because we maintain the generated
interfaces and their implementations together in the same repository
anyway, but adding the "unimplemented" server embeds was not a big change
and so seems better to follow the prevailing convention.

Using these new versions means that we could in principle now switch to
using protobuf edition 2024 and the new "sealed" style for Go code
generation, but this commit does not include any such changes and focuses
only on getting things upgraded with as few other changes as possible. We
can discuss using different codegen style later and deal with that in
separate commits.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-10-08 07:43:40 -07:00
Martin Atkins
b0cd4a3d8e go.mod: Update OpenTelemetry dependencies to v1.38.0
This is just a routine upgrade. Several of our other dependencies also
depend on these modules and so upgrading those others tends to ratchet up
these libraries. Therefore I'm upgrading them separately here really just
to allow subsequent upgrades of other dependencies without changing too
many dependencies at once in a single commit.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-10-07 11:36:57 -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
Martin Atkins
724a02cac9 CHANGELOG: Entry for opentofu/opentofu#3332
Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-10-06 16:27:26 -07:00
Martin Atkins
258f5ca795 go.mod: go get github.com/bmatcuk/doublestar/v4@v4.9.1
This is a routine dependency upgrade, but includes some behavior changes
that fix some upstream bugs:

- https://github.com/bmatcuk/doublestar/issues/96
- https://github.com/bmatcuk/doublestar/issues/88

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-10-06 16:27:26 -07:00
Martin Atkins
5faefe1f3d go.mod: go get github.com/hashicorp/jsonapi@v1.5.0
This is just a routine dependency upgrade.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-10-06 16:27:11 -07:00
Martin Atkins
56bc13d951 go.mod: go get github.com/xlab/treeprint@v1.2.0
This is just a routine dependency upgrade.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-10-06 16:26:49 -07:00
Martin Atkins
8e7dfdf478 dependencies: Stop using github.com/apparentlymart/go-dump
This upstream library (which I wrote, independently of my work on OpenTofu)
came about because "go-spew" tended to produce unreadable representations
of certain types commonly used in OpenTofu, whereas "go-dump" is really
just a pretty-printer for whatever a type might produce when formatted
using the %#v verb in package fmt.

Over time the uses of this seem to have decreased only to some leftover
situations where we wanted to pretty-print a cty.Value in a test, but
we already depend on go-cty-debug that has a more specialized
implementation of that behavior and so switching the few remaining callers
over to that allows us to remove one dependency.

(And, FWIW, that upstream dependency is effectively unmaintained; I don't
know of any callers of it other than OpenTofu itself, and after merging
this even OpenTofu won't depend on it anymore.)

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-10-06 12:47:32 -07:00
Diogenes Fernandes
f839281c15 Add CHANGELOG for module-enabled functionality
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-10-03 13:17:47 -03:00
Diogenes Fernandes
b2b6e84940 Meta-arguments validation source snippet
Previously, the source snippet was only showing the last defined
meta-argument. To have a better context of which meta-arguments
are being used, we start to show from the first one defined
until the last one.

Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-10-03 13:17:47 -03:00
Diogenes Fernandes
8736787762 Add module validation of for_each, enabled and count
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-10-03 13:17:47 -03:00
Diogenes Fernandes
22594c8afe Add tests for module lifecycle enabled
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-10-03 13:17:47 -03:00
Diogenes Fernandes
732623f604 Module expander for enabled field
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-10-03 13:17:47 -03:00
Diogenes Fernandes
ca53b2521d Add lifecycle block schema to ModuleCall
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-10-03 13:17:47 -03:00
Andrei Ciobanu
7bcc6464ed Add a note about the lack of feedback on the experimental encryption method and key_provider (#3323)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
Signed-off-by: Andrei Ciobanu <andreic9203@gmail.com>
Co-authored-by: Diógenes Fernandes <diofeher@gmail.com>
2025-10-03 15:33:46 +03:00
Diógenes Fernandes
a18063df8e fix: typo on the function's comment (#3324)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-10-02 12:36:01 -03:00
Mick Tarsel
cd21e74e75 Remove Community Supported Archs (#3321)
Signed-off-by: Mick Tarsel <mtarsel@gmail.com>
2025-09-30 19:12:05 -03:00
Martin Atkins
b8e67c0362 .github/workflows: Add windows_amd64 to unit test matrix (#3055)
Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-09-30 16:00:40 -03: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
Diógenes Fernandes
bdcf1f5e6e fix: internal/initwd tests on Windows (#3291) 2025-09-30 15:07:43 -03:00
Magicalcrow
4fbbea6f4b Fix typos in uuid and uuidv5 docs
Signed-off-by: Magicalcrow <simondiev@gmail.com>
2025-09-30 09:00:55 -07:00
Larry Bordowitz
bcbfebce3d Implement the Azure Key Provider
This uses the same auth package as the newly-rewritten Azure State
Backend, so many of the properties and environment variables are the
same. I have put this through both the compliance test as well as built
the binary and run some end-to-end tests, and found that it
appropriately uses the Azure key as expected.

Signed-off-by: Larry Bordowitz <laurence.bordowitz@gmail.com>
2025-09-29 06:19:02 -04:00
Martin Atkins
3b838464ab CHANGELOG: Entry for opentofu/opentofu#3292
Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-09-26 09:08:31 -07:00
Martin Atkins
9895f54ed0 lint: Include more source context in unused attribute diagnostics
From some more practical testing of this I realized that usually the first
thing I want to know after seeing this warning is what the object literal
was being assigned to and what else was also defined inside it, and so
this sets the diagnostic's "context" to include the whole containing
object literal so that the source snippet in the diagnostic message is more
immediately useful, without having to cross-reference to the source code
in a separate text editor.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-09-26 09:08:31 -07:00
Martin Atkins
0fb0a4b707 lint: DiscardedObjectConstructorAttrs
This generalizes the previously-added lint-like check for when an object
constructor is used to define an input variable and it contains a
definition for an attribute that isn't part of the target type, so that
now it also works for various nested structures that commonly arise in
real-world configurations.

Because this is now considerably more complicated I factored it out into
a new package called "lint" which could potentially grow to include other
similar "technically valid but probably a mistake" situations in future,
but for now it just introduced an opportunity to produce similar warning
messages for ignored attribute definitions in the default value for an
input variable.

It seems to me that there is actually no useful reason to include an
unexpected attribute definition in either of these two cases: that
attribute will never appear as part of any expression that any other part
of the configuration can use. Therefore I considered making these be
treated as errors rather than warnings, but turning something that was
previously valid into an error is risky so I'm suggesting that we start
with these as warnings and then consider upgrading them to errors in a
later release if we don't hear of anyone reporting a false-positive that
was _somehow_ actually useful. (I find that very unlikely, but still...)

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-09-26 09:08:31 -07:00
Martin Atkins
d7c4487172 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-26 09:08:31 -07:00
Diogenes Fernandes
b0704680c0 Better handling of the enabled types on the tofu/evaluate (#3042)
Co-Authored-by: Martin Atkins <mart@degeneration.co.uk>
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-09-26 08:44:39 -03:00
Diogenes Fernandes
774224a2dd Early return when having errors and additional tests (#3042)
Co-authored-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-09-26 08:44:39 -03:00
Diogenes Fernandes
1c90ca87f8 Implement validation on ephemeral and data resources (#3042)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-09-26 08:44:39 -03:00
Diogenes Fernandes
85ea2a4fa5 Improve eval_lifecycle_enabled diagnostic context for errors (#3042)
Co-Authored-By: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-09-26 08:44:39 -03:00
Diogenes Fernandes
f439baaf01 Fix variable context expansion on resources (#3042)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-09-26 08:44:39 -03:00
Diogenes Fernandes
0eb18fb49c Add conditional enabled field on managed and data resources (#3042)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-09-26 08:44:39 -03:00
Diógenes Fernandes
1b90a1889e Evaluate expressions for enabled meta-argument (#3250)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-09-26 08:44:39 -03:00
Diógenes Fernandes
493f44ef76 Fix typos in the diagnostics.md docs (#3306)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-09-25 15:10:14 +01:00