Commit graph

16 commits

Author SHA1 Message Date
Sarah French
f5a28cfa8b
PSS: Update how commands access backends, so both backend and state_store configuration can be used (#37569)
Some checks are pending
build / Build for windows_amd64 (push) Blocked by required conditions
build / Build for freebsd_arm (push) Blocked by required conditions
build / Build for linux_arm (push) Blocked by required conditions
build / Build for darwin_arm64 (push) Blocked by required conditions
build / Build for linux_arm64 (push) Blocked by required conditions
build / Build for windows_arm64 (push) Blocked by required conditions
build / Build Docker image for linux_386 (push) Blocked by required conditions
build / Build Docker image for linux_amd64 (push) Blocked by required conditions
build / Build Docker image for linux_arm (push) Blocked by required conditions
build / Build Docker image for linux_arm64 (push) Blocked by required conditions
build / Build e2etest for linux_386 (push) Blocked by required conditions
build / Build e2etest for windows_386 (push) Blocked by required conditions
build / Build e2etest for darwin_amd64 (push) Blocked by required conditions
build / Build e2etest for linux_amd64 (push) Blocked by required conditions
build / Build e2etest for windows_amd64 (push) Blocked by required conditions
build / Build e2etest for linux_arm (push) Blocked by required conditions
build / Build e2etest for darwin_arm64 (push) Blocked by required conditions
build / Build e2etest for linux_arm64 (push) Blocked by required conditions
build / Run e2e test for linux_386 (push) Blocked by required conditions
build / Run e2e test for windows_386 (push) Blocked by required conditions
build / Run e2e test for darwin_amd64 (push) Blocked by required conditions
build / Run e2e test for linux_amd64 (push) Blocked by required conditions
build / Run e2e test for windows_amd64 (push) Blocked by required conditions
build / Run e2e test for linux_arm (push) Blocked by required conditions
build / Run e2e test for linux_arm64 (push) Blocked by required conditions
build / Run terraform-exec test for linux amd64 (push) Blocked by required conditions
Quick Checks / Unit Tests (push) Waiting to run
Quick Checks / Race Tests (push) Waiting to run
Quick Checks / End-to-end Tests (push) Waiting to run
Quick Checks / Code Consistency Checks (push) Waiting to run
* Add a generic method for loading an operations backend in non-init commands

* Refactor commands to use new prepareBackend method: group 1

* Refactor commands to use new prepareBackend method: group 2, where config parsing needs to be explicitly added

* Refactor commands to use new prepareBackend method: group 3, where we can use already parsed config

* Additional, more nested, places where logic for accessing backends needs to be refactored

* Remove duplicated comment

* Add test coverage of `(m *Meta) prepareBackend()`

* Add TODO related to using plans for backend/state_store config in apply commands

* Add `testStateStoreMockWithChunkNegotiation` test helper

* Add assertions to tests about the backend (remote-state, local, etc) in use within operations backend

* Stop prepareBackend taking locks as argument

* Code comment in prepareBackend

* Replace c.Meta.prepareBackend with c.prepareBackend

* Change `c.Meta.loadSingleModule` to `c.loadSingleModule`

* Rename (Meta).prepareBackend to  (Meta).backend, update godoc comment to make relationship to (Meta).Backend more obvious.

* Revert change from config.Module to config.Root.Module

* Update `(m *Meta) backend` method to parse config itself, and also to adhere to calling code's viewtype instructions

* Update all tests and calling code following previous commit

* Change how an operations backend is obtained by autocomplete code

* Update autocomplete to return nil if no workspace names are returned from the backend

* Add test coverage for autocompleting workspace names when using a pluggable state store

* Fix output command: pass view type data to new `backend` method

* Fix in plan command: pass correct view type to `backend` method

* Fix `providers schema` command to use correct viewtype when preparing a backend
2025-11-03 17:57:20 +00:00
Sarah French
145e152a57
Clarify usage of BackendOpts, rename field in struct to enable usage with PSS in future (#37085)
* Update comments to distinguish between operations and state-storage backends more clearly

* Rename `BackendOpts` field `Config` to more specific `BackendConfig`
2025-07-11 11:08:56 +01:00
Liam Cervante
f3489c0480
deferred actions: should still be experimental (#37167) 2025-05-26 09:16:13 +02:00
Liam Cervante
c5445d4568
stacks: move the RPCAPI and deferred actions out of experimental (#37067)
* stacks: move the RPCAPI and deferred actions out of experimental

* add PR number
2025-05-16 11:11:55 +02:00
UKEME BASSEY
c7bbc09631 move all command args from command/init to args/init 2024-04-17 12:26:23 -04:00
Nick Fagerlund
1781c8e8e9 Experimental -allow-deferral flag for enabling deferred actions on CLI
Now that deferred actions is a top-level per-plan option, here's a lil
command-line option for turning it on!

- It's called `-allow-deferral`.
- It is ONLY legal to use if this is an experimental build, i.e. compiled with
  `go build -ldflags "-w -s -X 'main.experimentsAllowed=yes'"` or the like.

Implementation notes: The design constraint here was, "please avoid having to
change the build infrastructure or alter the function of every args parsing
function". So, since `extendedFlagSet()` doesn't have access to the var that
says we're in an experimental build, I had to move the validation for that
particular flag to later in the process, when we're building the operation
request.
2024-04-03 14:40:50 -07:00
Martin Atkins
88cb4aeea3 backendrun: Separate the types/etc for backends that support operations
We previously had all of the types and helpers for all kinds of backends
together in package backend. That kept things relatively simple, but it
also meant that the majority of backends that only deal with remote state
storage ended up still indirectly depending on the entire Terraform modules
runtime, configuration loader, etc, etc, which brings into scope a bunch
of external dependencies that the remote state backends don't really need.

Since backends that support operations are a rare exception, we'll move the
types and helpers for those into a separate package "backendrun", and
then the main package backend can have a much more modest set of types and,
more importantly, a modest set of dependencies on other packages in this
codebase.

This is part of an ongoing effort to reduce the exposure of Terraform Core
and CLI code to the remote backends and vice-versa, so that in the long
run we can more often treat them as separate for dependency maintenance
purposes.
2024-03-12 08:44:17 -07:00
Martin Atkins
b0b8d4aa6f states: Only track root module output values
For a very long time we've had an annoying discrepancy between the
in-memory state model and our state snapshot format where the in-memory
format stores output values for all modules whereas the snapshot format
only tracks the root module output values because those are all we
actually need to preserve between runs.

That design wart was a result of us using the state both as an internal
and an external artifact, due to having nowhere else to store the
transient values of non-root module output values while Terraform Core
does its work.

We now have namedvals.State to internally track all of the throwaway
results from named values that don't need to persist between runs, so now
we'll use that for our internal work instead and reserve the states.State
model only for the data that we will preserve between runs in state
snapshots.

The namedvals internal model isn't really designed to support enumerating
all of the output values for a particular module call, but our expression
evaluator currently depends on being able to do that and so we have a
temporary inefficient implementation of that which just scans the entire
table of values as a stopgap just to avoid this commit growing even larger
than it already is. In a future commit we'll rework the evaluator to
support the PartialEval mode and at the same time move the responsiblity
for enumerating all of the output values into the evaluator itself, since
it should be able to determine what it's expecting by analyzing the
configuration rather than just by trusting that earlier evaluation has
completed correctly.

Because our legacy state string serialization previously included output
values for all modules, some of our context tests were accidentally
depending on the implementation detail of how those got stored internally.
Those tests are updated here to test only the data that is a real part
of Terraform Core's result, by ensuring that the relevant data appears
somewhere either in a root output value or in a resource attribute.
2023-12-07 09:56:36 -08:00
hashicorp-copywrite[bot]
53c34ff49c
Update copyright file headers to BUSL-1.1 2023-08-10 23:43:27 +01:00
hashicorp-copywrite[bot]
325d18262e [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
zetHannes
c70244426a
Fix for no json output of state locking actions for --json flag (#32451)
* Add viewType to Meta object and use it at the call sites

* Assign viewType passed from flags to state-locking cli commands

* Remove temp files

* Set correct mode for statelocker depending on json flag passed to commands

* Add StateLocker interface conformation check for StateLockerJSON

* Remove empty line at end of comment

* Pass correct ViewType to StateLocker from Backend call chain

* Pass viewType to backend migration and initialization functions

* Remove json processing info in process comment

* Restore documentation style of backendMigrateOpts
2023-02-07 09:06:12 +01:00
kmoe
54b837416c
command: mention plan options in refresh help text (#30892)
* command: add parallelism option to refresh help text
2022-05-31 14:27:21 +01:00
Chris Arcand
6dc1fed6d5 Clarify legacy Ui comments 2021-10-28 19:29:21 -05:00
Barrett Clark
edbc84420c Run apply -refresh-state instead of refresh
When a user runs `terraform refresh` we give them an error message that
tells them to run `terraform apply -refresh-state`. We could just run
that command for them, though. That is what this PR does.
2021-10-28 19:29:12 -05:00
James Bardin
863963e7a6 de-linting 2021-09-01 11:36:21 -04:00
Martin Atkins
ffe056bacb Move command/ to internal/command/
This is part of a general effort to move all of Terraform's non-library
package surface under internal in order to reinforce that these are for
internal use within Terraform only.

If you were previously importing packages under this prefix into an
external codebase, you could pin to an earlier release tag as an interim
solution until you've make a plan to achieve the same functionality some
other way.
2021-05-17 14:09:07 -07:00
Renamed from command/refresh.go (Browse further)