Commit Graph

32446 Commits

Author SHA1 Message Date
Martin Atkins
6bd681e98f Process RFC: RFC Tracking Issues
Proposal for creating a separate "tracking issue" for each accepted RFC,
which represents the implementation of the features described in that RFC
separately from the potentially-many feature request issues it aims to
address.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-01-14 14:33:04 -08:00
Oleksandr Levchenkov
d7af2c4d39
update tofu console docs for non-interactive use-case (#2369)
Signed-off-by: ollevche <ollevche@gmail.com>
Signed-off-by: Oleksandr Levchenkov <ollevche@gmail.com>
Co-authored-by: AbstractionFactory <179820029+abstractionfactory@users.noreply.github.com>
2025-01-14 19:03:30 +02:00
AbstractionFactory
174f1d5784
Fixed broken links in encryption docs (#2366)
Signed-off-by: AbstractionFactory <179820029+abstractionfactory@users.noreply.github.com>
2025-01-13 16:00:48 +01:00
AbstractionFactory
b036e534b2
Fixing incorrect keyprovider-external.tofu (#2365)
Signed-off-by: AbstractionFactory <179820029+abstractionfactory@users.noreply.github.com>
2025-01-13 15:53:05 +01:00
Christian Mesh
52816a96dc
Run make generate protobufs (#2360)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2025-01-10 11:34:33 -05:00
Martin Atkins
3cbedd3817 plans/objchange: Split assertNestedBlockCompatibleMap into two parts
Unlike the other nesting modes, we need to use some quite different code
for comparing object-backed vs. map-backed blocks, which are both possible
interpretations of the NestingMap mode depending on whether the inner
block type has any dynamically-typed attributes.

Therefore we split that case into two parts depending on what type kind
we find, so that each of the parts can then be shaped more like the other
type-specific variants of assertNestedBlockCompatible. (This also removes
one level of if nesting to placate the nestif linter.)

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-01-10 08:29:58 -08:00
Martin Atkins
5b59d869bf plans/objchange: Decompose type-specific part of assertValueCompatible
This function starts with a general part that deals with conditions that
are common to all types, but then dispatches into different codepaths
depending on the type kind.

To keep the main function shorter, here we decompose the type-kind-specific
handling into separate functions, making assertValueCompatible now end
with a simpler dispatch table.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-01-10 08:29:58 -08:00
Martin Atkins
d49f997b65 plans/objchange: Decompose assertNestedBlockCompatible
The main function is now just a jump table into a separate function for
each nesting mode. The observable behavior is unchanged.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-01-10 08:29:58 -08:00
Martin Atkins
55ff663aff plans/objchange: Decompose assertObjectCompatible a little
This splits out the handling of individual attributes and individual nested
block types into separate functions, thereby reducing the length and
complexity of the top-level function.

As of this commit, assertNestedBlockCompatible is still too long to pass
our current function length linting limit, but we'll address that in a
later commit to avoid changing too much at once.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-01-10 08:29:58 -08:00
Martin Atkins
e70913a609 plans/objchange: Fix go vet warnings
Passing the result of fmt.Sprintf as the format string to path.NewErrorf
is redundant. It can also potentially cause problems if the result would
also contain formatting verbs, although in this case the input is under
this function's full control so this was just a waste of time rather than
a behavior problem.

Go error strings also conventionally start with lowercase letters and act
as sentence fragments rather than full sentences, so the prefix used for
a zero-length path is now "root object" instead of "Root object".

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-01-10 08:29:58 -08:00
James Humphries
c1f1008723
Replace mock module with go.uber.org/mock (#1673)
Signed-off-by: Mikel Olasagasti Uranga <mikel@olasagasti.info>
Signed-off-by: James Humphries <james@james-humphries.co.uk>
Co-authored-by: Mikel Olasagasti Uranga <mikel@olasagasti.info>
2025-01-10 08:29:20 -05:00
Martin Atkins
7435a49e4a
plans/objchange: Decompose normalizeObjectFromLegacySDK a little (#2353)
Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-01-10 08:28:13 -05:00
AbstractionFactory
09403c7328
Docs prep for 1.10 (#2357)
Signed-off-by: AbstractionFactory <179820029+abstractionfactory@users.noreply.github.com>
2025-01-10 11:40:17 +01:00
Martin Atkins
d0d35d2dcd tfplugin5+tfplugin6: Update to latest protocol schema
This commit adds the definitions of provider protocol 5.6, 5.7, 6.6, and
6.7 to our archive of the historical protocol versions and then adopts
5.7 as the current version of major version 5 and 6.7 as the current
version of major version 6.

These MPL-licensed schema definitions are from the plugin protocol server
implementation in this repository, copyright HashiCorp:
    https://github.com/hashicorp/terraform-plugin-go

The only modifications made are to change the "option go_package" directive
to match where the stubs need to be generated for OpenTofu, and to claim
copyright for that change and thus make the copyright header consistent
with what our pre-commit rules require.

The regeneration of the Go API stubs for the two major protocol versions
introduces some new fields and messages that OpenTofu does not yet support
but will happily ignore. Future work might make some use of these new
additions, but that's out of scope of this change that is intended only
to synchronize our protocol definition with what new plugin server releases
are likely to be linked against.

This commit continues the existing precedent of having the stubs for the
newly-added interface methods in package grpcwrap being just a panicking
stub, which is how they will remain until a future project begins using
those methods in a way which requires them to be implemented, since
implementing the wrappers would require a deeper understanding of the
desired behavior of those methods.

It appears that we previously accepted a pull request to correct a typo
that originated in the older versions of the upstream protocol definitions,
but I have intentionally not forward-ported that here because it seems
clearer to keep these definitions as close as possible to their source
of truth from upstream, given that our current intention is to follow the
protocol as documented and not to change it.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-01-09 16:16:58 -08:00
Marcin Wyszynski
f83849e95a
Catch invalid name in provider_meta before it causes a crash (#2347)
Signed-off-by: Marcin Wyszynski <marcin.pixie@gmail.com>
2025-01-09 14:36:56 +00:00
Oleksandr Levchenkov
76d388b340
fix: provider not initialized in some cases (mostly, deposed) (#2335)
Signed-off-by: ollevche <ollevche@gmail.com>
Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
Co-authored-by: Martin Atkins <mart@degeneration.co.uk>
2025-01-08 12:34:52 -05:00
AbstractionFactory
5a6d2d3e98
Fixes #2022: Running external commands as a key provider (#2023)
Signed-off-by: AbstractionFactory <179820029+abstractionfactory@users.noreply.github.com>
Signed-off-by: ollevche <ollevche@gmail.com>
Co-authored-by: Oleksandr Levchenkov <ollevche@gmail.com>
2025-01-08 12:08:30 -05:00
zcxsythenew
ec20752054
Add option "-json" in help text of apply command and plan command. (#2340)
Signed-off-by: Guozhang Wu <30565051+zcxsythenew@users.noreply.github.com>
2025-01-08 14:58:32 +02:00
Oleksandr Levchenkov
8139ae6005
update MAINTAINERS file (#2341)
Signed-off-by: ollevche <ollevche@gmail.com>
2025-01-08 10:52:42 +01:00
AbstractionFactory
3033dba76a
OpenTofu 1.10: Disable usage of ghcr.io image as a base image (#1994)
Signed-off-by: Janos <179820029+abstractionfactory@users.noreply.github.com>
Signed-off-by: abstractionfactory <179820029+abstractionfactory@users.noreply.github.com>
Signed-off-by: AbstractionFactory <179820029+abstractionfactory@users.noreply.github.com>
2025-01-07 10:08:23 -05:00
Jon Johnson
7ba6e61c69
Fix quadratic marshalPlannedValues (#2324)
Signed-off-by: Jon Johnson <jon.johnson@chainguard.dev>
Signed-off-by: Jon Johnson <jonjohnsonjr@gmail.com>
Co-authored-by: Oleksandr Levchenkov <ollevche@gmail.com>
2025-01-06 16:20:41 -05:00
Martin Atkins
45131c4c0c lang: Split enhanceFunctionDiags loop body into separate function
This function was previously failing the nestif lint rule. Factoring the
loop body out into a separate function avoids that problem and also
subjectively makes this easier to follow by separating the functional-style
enhanceFunctionDiag from the mutation of the backing array of the caller's
diags slice.

This also transforms enhanceFunctionDiags into a package-level function
rather than a method of Scope, since in practice it doesn't actually use
anything from Scope.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-01-06 08:39:01 -08:00
Martin Atkins
972324e5ea lang: Factor out the base function table
Whichever function were responsible for instantiating this map would
inevitably end up scaling in length based on the number of funtions and
thus violate the function length linter.

As a compromise, we'll factor out the function table into its own function
that is exempt from that linter but focused only on constructing the base
function table, and then Scope.Functions can be shorter by dealing only
with the scope-specific customizations of the returned table.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-01-06 08:39:01 -08:00
Martin Atkins
69bf43dd56 repl: Various lint-related updates
This is an assortment of small changes to fix all of the remaining lint
failures in this package, based on our current golangci-lint configuration.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-01-06 08:38:44 -08:00
Martin Atkins
da8a2ecfce repl: break typeString into some smaller functions
This function was too long for our function length linting rule, so we'll
split each of the type kinds with special handling into their own function
and thus the main typeString function is just a straightforward dispatch
table with only one statement per case.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-01-06 08:38:44 -08:00
Martin Atkins
6cc3fc6a07 repl: FormatValue factor out printing of null values
This value was too long for our function length lint rule, and factoring
out the printing of null values makes this more balanced with how we're
already handling unknown values and sensitive values so that the main
body of FormatValue is focused on the normal value printing case.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-01-06 08:38:44 -08:00
Martin Atkins
547bb32cee statefile: old version upgrades exempt from linters
The functions in these files are for handling older state snapshot formats
that current OpenTofu versions never generate, and so it's highly unlikely
that we'll ever make substantial changes to these functions.

Therefore it's unjustified to risk reworking it to pass linting rules, and
so we'll add nolint comments instead. Our priority is to make as few
changes as possible to these functions, to minimize the risk of regressing
a upgrade paths that are exercised very infrequently.

(For context, state version 4 has been current ever since Terraform
v0.12.0, and so the earlier versions are long obsolete.)

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-01-06 08:38:15 -08:00
Martin Atkins
1551f1d6cf legacy packages: Exempt from complexity linters
These packages are frozen copies of old code from much older versions of
the product that are preserved to keep the state storage backends working
until we decide on a way to get them out of this codebase entirely.

Therefore the only potential future change to this code is to delete it
once it's no longer needed. It would not be worth the risk or time
investment to rework these to meet our strict complexity linting rules.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-01-06 08:37:54 -08:00
Martin Atkins
9d9c1486fa ipaddr: Exempt from all lint rules
The code in this package is all snapshot from the Go codebase in older
versions, inlined here to allow OpenTofu's cidr-calculation-related
functions to preserve their original behavior despite upstream changing
the parsing rules in a breaking way.

This code is intentionally modified as little as possible from the upstream
code it was derived from. We are imposing on ourselves considerably
stricter style conventions than the Go project follows and so we need
to disable various linters for this package to allow this code to remain
written in the Go idiomatic style, rather than in OpenTofu's stricter
local style.

In particular, we've chosen to prohibit ourselves from using named return
values or package-global variables, despite those both being typical in the
standard library and in other codebases.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-01-06 08:36:42 -08:00
Martin Atkins
ad32bde2ae Temporarily disable the complexity-related lint rules
We're intending to gradually improve all of the existing functions that
fail these checks as a separate project from other work, because fixing
for these particular lint rules tends to be too invasive to be safe or
sensible to combine with other work.

Therefore we'll temporarily disable these lints from the main lint run
and add a separate .golangci-complexity.yml that we can use to track our
progress towards eliminating those lint failures without continuing to
litter the code with nolint comments in the meantime.

This also removes all of the existing nolint comments for these linters so
that we can start fresh and review each one as part of our improvement
project.

We'll re-enable these linters (and remove .golangci-complexity.yml) once
each example has either been rewritten to pass the checks or we've
concluded that further decomposition would hurt readability and so added
"nolint" comments back in so we can review whether our lint rules are too
strict once we've got a bunch of examples to consider together.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-01-03 10:41:05 -05:00
Martin Atkins
f802281c5a rfc: A Pragmatic Approach to Linting for Code Complexity
We currently have a set of aspirational linting rules in the project's
golangci-lint configuration, but this codebase was derived from a much
older codebase that was not written under those lint rules and so we made
the pragmatic decision that only code that has changed since the addition
of the lint rules is subjected to those lint rules.

That approach aims to make the compromise of encouraging us to gradually
improve code "while we're in the area" working on other changes, while
avoiding the need for a huge retrofit of existing code.

However, that compromise seems to be less appropriate for the subset of
linting rules related to code complexity in particular. That category of
rules typically imposes some arbitrary limit on a qualitative metric that
the linting tool can measure. These particular rules therefore have a
relatively broad scope and tend to require very disruptive changes to
existing code in order to resolve them.

This proposal aims to find a pragmatic path that will lead to a codebase
that _does_ conform to the complexity lint rules in the long run, but to
treat those improvements as a separate project in their own right rather
than as something we aim to gradually improve as part of other work.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-01-02 13:35:50 -08:00
Jon Johnson
c280c23b4c
configs: Fix quadratic buildChildModules
By building a map from module path to snapshotModule we can avoid repeatedly scanning the set of modules for each call to Open.

Signed-off-by: Jon Johnson <jon.johnson@chainguard.dev>
2025-01-02 13:29:03 -08:00
Martin Atkins
3dbf8aae7b tofu: eval_iteration.go is now eval_expansion.go
Using the word "iteration" to describe what count and for_each do tends to
confuse people because it sounds like explicit control flow rather than
just dynamically declaring multiple objects.

Elsewhere in the codebase we refer to this idea as "expansion" so this is
a rename for consistency with that and to remove the confusing terminology.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-01-02 13:24:11 -08:00
Martin Atkins
1e0d1050e8 CHANGELOG: A supplemental enhancement related to -exclude
Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-01-02 13:24:11 -08:00
Martin Atkins
f1358f9fe8 evalchecks: Suggest -exclude as a workaround for unknown count/for_each
Previously we made a very generic suggestion to use -target to split a
change into two parts as a workaround for the fact that count and for_each
must be known during planning. That works, but we didn't have enough
information available to tell the operator exactly what to target and so
anyone who is not an expert on the configuration they're working with tends
to get stuck unable to figure out exactly what they need to do.

The new -exclude option gives us an opportunity to do better here: we tend
to know for which object we're currently evaluating count or for_each, and
so we can mention that object directly in the error message when if we
recommend to use -exclude instead of -target.

Not all objects that support count/for_each will necessarily be directly
targetable, so we can still potentially recommend -target when we're
dealing with one of those objects. For example, as of this commit that
is true for for_each in a provider block, because there is not currently
any syntax for specifying a provider configuration as an addrs.Targetable.
Perhaps we'll introduce such a thing in the future, but that's outside the
scope of this change that's primarily focused on improving the messaging
for resource and module count/for_each.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-01-02 13:24:11 -08:00
Oleksandr Levchenkov
be5b14625d
fix randomly failing destroyed_mod_outputs test (#2315)
Signed-off-by: ollevche <ollevche@gmail.com>
2024-12-30 16:38:27 +02:00
Oleksandr Levchenkov
3945b3c93a
bump golang.org/x/net from 0.25 to 0.33 (#2311)
Signed-off-by: ollevche <ollevche@gmail.com>
2024-12-26 15:13:05 +02:00
Ilia Gogotchuri
2d9cef1f55
Functions: decode_tfvars, encode_tfvars, encode_expr on bult-in provider for compatibility (#2306)
Signed-off-by: Ilia Gogotchuri <ilia.gogotchuri0@gmail.com>
Co-authored-by: Oleksandr Levchenkov <ollevche@gmail.com>
2024-12-25 13:21:59 +04:00
Oleksandr Levchenkov
c5b43b9f1a
fix: unused config's create_before_destroy on resource change with no refresh (#2248)
Signed-off-by: ollevche <ollevche@gmail.com>
2024-12-20 10:47:00 +02:00
Sekiranda Hamza
211ec55a30
Skip reading encryption keys on tofu init with -backend=false flag set (#2293)
Signed-off-by: Sekiranda <sekirandahamza@gmail.com>
2024-12-20 10:45:12 +02:00
Martin Atkins
27ab52fd03
Compare ModuleInstance to Module without allocating, and similar (#2261)
Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2024-12-12 12:47:57 -05:00
Christian Mesh
73e4a657ae
Bump main to 1.10.0-alpha1 now that 1.9 has been branched (#2291)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2024-12-12 12:13:54 -05:00
dependabot[bot]
cdd86f2b38
Bump golang.org/x/crypto from 0.21.0 to 0.31.0 (#2287)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-12-12 08:50:09 -05:00
Martin Atkins
954e3aed01 rfc: Static Evaluation of Provider Iteration state tracking revision
The original proposal called for the state snapshot loader to accept a
resource instance with both an instance-level provider instance address
and a resource-level provider instance address.

The final implementation does follow that specification, but it also emits
a warning in that case to draw attention to the inconsistency.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2024-12-11 12:52:50 -08:00
Martin Atkins
b480343798 rfc: Static Evaluation of Provider Iteration state tracking revision
The original proposal called for the state snapshot writer to generate a
resource-level provider property if all of the instances of the resource
had the same provider instance address, regardless of what that address
actually is.

The actual implementation instead chose to generate the resource-level
property only if none of the instances of the resource refer to a provider
instance that has an instance key.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2024-12-11 12:52:50 -08:00
Christian Mesh
00bc17917a Require static scope stack to have at least one entry
Kind of odd code smell, but the only alternative I could think of was a
panic.  Would rather ensure this requirement at compile time instead.

Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2024-12-11 10:14:49 -08:00
Martin Atkins
7fdc4909d6 configs: Some basic tests for StaticScope's GetLocalValue
Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2024-12-11 10:14:49 -08:00
Martin Atkins
083e5f2e1c configs: Early eval must "finalize" input variable values
In the main language runtime input variables have both a "raw" value as
provided by the caller and a "finalized" value that has been
type-converted, default-attributes-inserted, and validated.

Unfortunately the "early eval" codepath is essentially a reimplementation
of the language runtime in terms of data available in the static
configuration, and it previously wasn't properly emulating the finalization
of input variable values and was thus incorrectly exposing the "raw"
values into a module instead of the "finalized" values.

Since we are already in the v1.9 prerelease period significant refactoring
is too risky, and so this just copies the most important transformations
from the language runtime into the early eval runtime. We hope to find a
more sustainable way to implement this in the future, but that will likely
require refactoring of both the early eval codepath _and_ the traditional
language runtime, and so that work needs to begin early in a minor release
period.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2024-12-11 10:14:49 -08:00
Ilia Gogotchuri
267b7f6008
Warn user about provider version 0.0.0 (#2281)
Signed-off-by: Ilia Gogotchuri <ilia.gogotchuri0@gmail.com>
2024-12-11 21:10:49 +04:00
I S
c433f87c58
Update TSC_SUMMARY.md (#2279)
Signed-off-by: I S <igor@scalr.com>
2024-12-11 08:40:19 -08:00