94 Commits

Author SHA1 Message Date
Ilia Gogotchuri
ce5944085f Retaining resource during destruction - action and reason marshalling extension (#3569)
Signed-off-by: Ilia Gogotchuri <ilia.gogotchuri0@gmail.com>
2025-12-12 15:16:54 +04:00
Ilia Gogotchuri
fd19a3763f Retain resource instances with a new lifecycle argument - destroy (#3409)
Signed-off-by: Ilia Gogotchuri <ilia.gogotchuri0@gmail.com>
Co-authored-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2025-12-04 18:49:57 +04: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
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
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
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
Andrei Ciobanu
4077c3d84f Feature branch: Ephemeral resources (#2852)
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2025-08-04 16:39:12 +03:00
Ilia Gogotchuri
dd2ace53e2 Diffing lists containing multiline strings (#3030)
Signed-off-by: Ilia Gogotchuri <ilia.gogotchuri0@gmail.com>
2025-07-18 20:44:05 +04:00
Diogenes Fernandes
18b2cb2100 refactor: make jsonentities dependent of jsonformat/structured
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-07-14 17:25:24 -03:00
Diogenes Fernandes
4a4d06cee1 refactor: break the dependency between jsonformat/computed/renderers and command/format
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-07-14 17:25:24 -03:00
Diógenes Fernandes
3ff2dedd4b refactor: separate entities from views/json into a new package (#3025)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-07-14 14:12:03 -03:00
Martin Atkins
647ea6a645 jsonformat: Tolerate incorrect paths in plan relevant_attributes
The code for matching relevant_attributes against resource_drift entries
(a part of the heuristic for deciding whether to show "changes outside of
OpenTofu" in the human-oriented plan UI) was previously assuming that paths
in resource_drift would always be valid for the associated resource
instance object values because in most cases the language runtime will
detect invalid references and so fail to generate a plan at all.

However, when the reference is to something within a dynamically-typed
argument (such as the manifest in kubernetes_manifest) and when it appears
only as an argument to either the "try" or "can" functions (so the dynamic
error is intentionally suppressed) the language runtime can't catch it
and so the incorrect reference will leak out into relevant_attributes,
thereby violating assumptions made by the path matcher.

Instead then, we'll continue the existing precedent that this "relevant
attributes" mechanism is a best-effort heuristic that prefers to succeed
with an incomplete result rather than to fail, extending that to the
traversals in the plan renderer which will now treat incorrectly-typed
steps as not matching rather than causing OpenTofu to crash completely.

Since a reference to something that doesn't exist cannot succeed it also
cannot possibly _actually_ contribute directly to the final result of the
expression it appeared in, so in practice it should be okay to disregard
these invalid references for the purposes of deciding which changes outside
of OpenTofu seem likely to have caused the actions that OpenTofu is
proposing to make during the apply phase.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-07-03 08:50:12 -07:00
Martin Atkins
32082321bf providers: Interface now requires context.Context arguments
Continuing our work to gradually plumb context.Context to everywhere that
we want to generate OpenTelemetry traces, this completes the call path
for most (but not all) of the gRPC requests to provider plugins, so that
we can add OpenTelemetry trace instrumentation in a future commit.

Unfortunately there are still a few providers.Interface callers left in
functions that don't have context.Context plumbed to them yet, and so
those are temporarily stubbed as context.TODO() here so we can more easily
find and complete them later.

The two gRPC implementations of providers.Interface were previously making
provider requests using a single context.Context established at the time
the provider process was started, but that isn't an appropriate context
to use for per-request concerns like tracing, so that context is now
unused and could potentially be removed in a future commit, but this change
already got pretty large and so I intend to deal with that separately
later.

This now exposes the gRPC provider calls to potential context cancellation
that they would previously observe only indirectly though the Stop method.
Since Stop is primarily used for graceful shutdown of ApplyResourceChange,
the changes here explicitly disconnect the cancellation signal for
ApplyResourceChange in particular, while letting the others get canceled
in the normal way since they are expected to be free of significant
side-effects. In future work we could consider removing Stop from the
internal API entirely and keeping it only as an implementation detail of
the gRPC implementation of this interface, with ApplyResourceChange
directly reacting to context cancellation and sending the gRPC Stop call
itself, but again that's too much change for this already-large commit.

The internal/legacy package currently contains some legacy code preserved
for the benefit of the backends, and unfortunately contains more than is
strictly necessary to support those callers, and so there was some dead
code there that also needed updating. provider_mock.go is removed entirely
because it's just an older copy of the similar file in package tofu. The
few calls to providers in schemas.go are updated to use
context.Background() rather than context.TODO() because we have no
intention of plumbing context.Context into that legacy code, and will
hopefully just delete it wholesale one day.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-05-23 08:58:23 -07:00
Christian Mesh
aaed9f83e4 Fix linting in internal/command (#2798)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2025-05-15 07:39:11 -04:00
Oleksandr Levchenkov
82d71e50e8 add deprecation warnings support for terraform_remote_state (#2679)
Signed-off-by: ollevche <ollevche@gmail.com>
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Co-authored-by: Christian Mesh <christianmesh1@gmail.com>
2025-04-25 12:26:28 +03:00
Mikel Olasagasti Uranga
66765bdab3 Fix: Ensure constant format strings in fmt and printf calls
Go 1.24 introduces stricter checks for format string validation.
This commit fixes instances where non-constant format strings were
used in calls to functions like `fmt.Errorf`, `fmt.Printf`, and similar.

Changes include:
- Replacing dynamically constructed strings passed as format strings
with constant format strings.
- Refactoring `fmt.Sprintf` calls to ensure the format string matches
the number of arguments provided.
- Simplifying redundant formatting and ensuring compliance with Go
1.24's stricter `vet` tool checks.

This update ensures compatibility with Go 1.24 and prevents potential
runtime errors caused by misinterpreted dynamic format strings.

Resolves #2389

Signed-off-by: Mikel Olasagasti Uranga <mikel@olasagasti.info>
Co-authored-by: Martin Atkins <mart@degeneration.co.uk>
Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-02-26 11:33:43 -08:00
Jarrett Duskey
ecd4dc5c61 Add count of forgotten resources to plan and apply outputs. (#2010)
Signed-off-by: Jarrett Duskey <jarrett@duskey.io>
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Co-authored-by: Christian Mesh <christianmesh1@gmail.com>
2025-02-24 14:53:32 -05:00
Christian Mesh
fd775f0fe3 Implement Provider for_each (#2105)
Signed-off-by: ollevche <ollevche@gmail.com>
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Signed-off-by: Ronny Orot <ronny.orot@gmail.com>
Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
Co-authored-by: ollevche <ollevche@gmail.com>
Co-authored-by: Ronny Orot <ronny.orot@gmail.com>
Co-authored-by: Martin Atkins <mart@degeneration.co.uk>
2024-11-05 18:08:23 -05:00
Burak Şen
854c49e04b Fix all unknown block not outputted (#1948)
Signed-off-by: buraksenn <buraksenb@gmail.com>
2024-09-17 09:49:33 -04:00
Burak Şen
2091c96984 Fix setops not used in block set renderer (#1950)
Signed-off-by: buraksenn <buraksenb@gmail.com>
2024-09-17 09:36:35 -04:00
Siddhartha Sonker
579d74c409 Add -show-sensitive flag to tofu plan, apply, state-show and output commands (#1554)
Signed-off-by: siddharthasonker95 <158144589+siddharthasonker95@users.noreply.github.com>
2024-07-22 10:58:57 +01:00
Syasusu
c0f6b189b5 fix: large number are truncated in plan (#1382)
Signed-off-by: Syasusu <syasusu@163.com>
2024-03-26 07:18:59 -04:00
Ronny Orot
e9fe0f1118 Add support for removed block (#1158)
Signed-off-by: Ronny Orot <ronny.orot@gmail.com>
2024-02-21 10:31:44 +02:00
Shashwat Pandey
3d30842cf0 306 concise mode for plan (#1225)
Signed-off-by: Shashwat Pandey <72958686+SypherSP@users.noreply.github.com>
2024-02-14 13:21:35 +01:00
namgyalangmo
cb2e9119aa Update copyright notice (#1232)
Signed-off-by: namgyalangmo <75657887+namgyalangmo@users.noreply.github.com>
2024-02-08 09:48:59 +00:00
RLRabinowitz
8967cdcee7 Remove all Terraform Cloud mentions in STDOUTs in the codebase (#703) 2023-10-12 12:07:16 +01:00
Yaron Yarimi
487d9bc6a4 Rename multiple packages to OpenTofu (addrs, backend, command) (#506) 2023-09-21 15:38:46 +03:00
Yaron Yarimi
794e3413bb Rename opentf package to tofu (#466) 2023-09-20 15:16:53 +03:00
Yaron Yarimi
c8acedd885 Rename github.com/placeholderplaceholderplaceholder/opentf to github.com/opentofu/opentofu (#461) 2023-09-20 14:35:35 +03:00
RLRabinowitz
90dce4dd3c go fmt, change import order 2023-08-28 14:22:54 +03:00
RLRabinowitz
42e7c5b25c Replace internal/terraform -> internal/opentf 2023-08-28 14:21:34 +03:00
Elbaz
3dd3381ca4 update 2023-08-22 17:34:37 +03:00
Yaron Yarimi
67e9d1f2e4 Merge branch 'main' of github.com:opentffoundation/opentf into chore-rename-terraform-to-opentf-in-docs 2023-08-22 16:22:24 +03:00
Yaron Yarimi
24beb7ee5c Renaming terraform to opentf 2023-08-22 15:45:05 +03:00
Elbaz
af8f424985 fix more tests 2023-08-22 12:03:38 +03:00
Elbaz
612238fe38 fix more tests 2023-08-22 11:59:26 +03:00
Elbaz
141e72246d fix tests + english 2023-08-21 19:33:20 +03:00
Kuba Martin
ebcf7455eb Rename root module name. (#4)
* Rename module name from "github.com/hashicorp/terraform" to "github.com/placeholderplaceholderplaceholder/opentf".

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* Gofmt.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* Regenerate protobuf.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* Fix comments.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* Undo issue and pull request link changes.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* Undo comment changes.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* Fix comment.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* Undo some link changes.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* make generate && make protobuf

Signed-off-by: Jakub Martin <kubam@spacelift.io>

---------

Signed-off-by: Jakub Martin <kubam@spacelift.io>
2023-08-17 14:45:11 +02:00
Nick Fagerlund
0df3c143bb New plans.Quality type for display-relevant facts about a plan
This commit replaces the existing jsonformat.PlanRendererOpt type with a new
type with identical semantics, located in the plans package.

We needed to be able to exchange the facts represented by
`jsonformat.PlanRendererOpt` across some package boundaries, but the jsonformat
package is implicated in too many dependency chains to be safe for that purpose!
So, we had to make a new one. The plans package seems safe to import from all
the places that must emit or accept this info, and already contains plans.Mode,
which is effectively a sibling of this type.
2023-07-24 14:12:44 -04:00
James Bardin
cf5ebaf685 s/Schemas/ProviderSchema/ 2023-07-06 10:37:35 -04:00
James Bardin
36d34135ad replace remaining types in tests 2023-07-06 10:37:35 -04:00
Liam Cervante
3613e972c5 Plan renderer: Support users indexing integer paths with stringified numbers (#33475) 2023-07-05 11:11:02 +02:00
kmoe
b4d1146f58 plannable import: improve gen config human plan output (#33194)
* renderer: remove hard-coded config gen path

* mention config gen file in plan next steps
2023-05-15 15:21:41 +01:00
Liam Cervante
4d837df546 Plannable import: Add generated config to JSON and human-readable plan output (#33154)
* command: keep our promises

* remove some nil config checks

Remove some of the safety checks that ensure plan nodes have config attached at the appropriate time.

* add GeneratedConfig to plan changes objects

Add a new GeneratedConfig field alongside Importing in plan changes.

* add config generation package

The genconfig package implements HCL config generation from provider state values.

Thanks to @mildwonkey whose implementation of terraform add is the basis for this package.

* generate config during plan

If a resource is being imported and does not already have config, attempt to generate that config during planning. The config is generated from the state as an HCL string, and then parsed back into an hcl.Body to attach to the plan graph node.

The generated config string is attached to the change emitted by the plan.

* complete config generation prototype, and add tests

* Plannable import: Add generated config to json and human-readable plan output

---------

Co-authored-by: Katy Moe <katy@katy.moe>
2023-05-11 08:50:03 +02:00
hashicorp-copywrite[bot]
bb36298b21 [COMPLIANCE] Add Copyright and License Headers 2023-05-08 15:47:42 -07:00
Liam Cervante
77f10c4f68 Imports should come before Adds in change summaries (#33147) 2023-05-04 15:06:48 +02:00
Liam Cervante
54c1c1162f [Plannable Import] Implement human-readable plan rendering (#33113)
* [plannable import] embed the resource id within the changes

* add the plannable imports to the json and human plans

* latest importing struct
2023-05-03 18:50:04 +02:00
hashicorp-copywrite[bot]
325d18262e [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00