Commit graph

1167 commits

Author SHA1 Message Date
Sarah French
008c92d91f
fix: Append lost warnings in MaybeGetSchemas (#38605)
Some checks are pending
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 for linux_s390x (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 Docker image for linux_s390x (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
2026-05-18 16:35:56 +01:00
Sarah French
d174972029
test: Show warning when a -filter flag has an invalid value (#38603)
Some checks failed
build / Build for openbsd_amd64 (push) Has been cancelled
build / Build for solaris_amd64 (push) Has been cancelled
build / Build for windows_amd64 (push) Has been cancelled
build / Build for freebsd_arm (push) Has been cancelled
build / Build for linux_arm (push) Has been cancelled
build / Build for darwin_arm64 (push) Has been cancelled
build / Build for linux_arm64 (push) Has been cancelled
build / Build for windows_arm64 (push) Has been cancelled
build / Build for linux_s390x (push) Has been cancelled
build / Build Docker image for linux_386 (push) Has been cancelled
build / Build Docker image for linux_amd64 (push) Has been cancelled
build / Build Docker image for linux_arm (push) Has been cancelled
build / Build Docker image for linux_arm64 (push) Has been cancelled
build / Build Docker image for linux_s390x (push) Has been cancelled
build / Build e2etest for linux_386 (push) Has been cancelled
build / Build e2etest for windows_386 (push) Has been cancelled
build / Build e2etest for darwin_amd64 (push) Has been cancelled
build / Build e2etest for linux_amd64 (push) Has been cancelled
build / Build e2etest for windows_amd64 (push) Has been cancelled
build / Build e2etest for linux_arm (push) Has been cancelled
build / Build e2etest for darwin_arm64 (push) Has been cancelled
build / Build e2etest for linux_arm64 (push) Has been cancelled
build / Run e2e test for linux_386 (push) Has been cancelled
build / Run e2e test for windows_386 (push) Has been cancelled
build / Run e2e test for darwin_amd64 (push) Has been cancelled
build / Run e2e test for linux_amd64 (push) Has been cancelled
build / Run e2e test for windows_amd64 (push) Has been cancelled
build / Run e2e test for linux_arm (push) Has been cancelled
build / Run e2e test for linux_arm64 (push) Has been cancelled
build / Run terraform-exec test for linux amd64 (push) Has been cancelled
* test: Show warning when a test file filter is not valid

* Add change file
2026-05-15 20:36:26 +01:00
Sebastien Tardif
3c94ef65b3
Fix resource leaks in provisioners and commands (#38585)
* Fix resource leaks in provisioners and commands

Close file handles, HTTP response bodies, and pipe ends that were
previously leaked on certain code paths:

- workspace_new.go: Close state file opened via os.Open
- file/resource_provisioner.go: Close temp file handle before returning
  the file path to caller
- login.go: Move defer resp.Body.Close() before ioutil.ReadAll so the
  body is closed even when ReadAll fails
- local-exec/resource_provisioner.go: Close the read end of os.Pipe
  after the copy goroutine completes

---------

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
2026-05-14 17:36:12 +01:00
Sarah French
820f37b35f
test: Proof of path traversals not being accepted workspaces (#38589) 2026-05-14 16:15:46 +01:00
Sarah French
c56ec2943d
refactor: Move validation of init's -upgrade and -lockfile=readonly flags to the arguments package. (#38561)
Some checks are pending
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 for linux_s390x (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 Docker image for linux_s390x (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
The `-upgrade` and `-lockfile=readonly` flags are mutually exclusive, and this is now enforced by the arguments package. This refactor has also fixed a historical bug where that validation error was output twice.

The getProvidersFromConfig code now depends on the flag validation happening in the calling code. However there is another check in downstream code, in `saveDependencyLockFile` when we overwrite the dependency lock file's contents. There, an error occurs if a diff in the locks is detected during `readonly` mode. This protects against incorrect use of `getProvidersFromConfig` with unvalidated inputs, if that happens in future.
2026-05-14 14:42:31 +01:00
Sarah French
2e5a89ab6f
Update command help text for state migrate command (#38571)
Added details about the default behaviour for the lock-file CLI flags, and made it clearer that the upgrade flag only enables upgrading the provider used for state storage.
2026-05-14 13:31:48 +01:00
Sarah French
adcf9a9cb3
PSS: Make sure to close supplementary instances of a store that are intended to be used temporarily. (#38573)
* feat : Add Close method to Pluggable struct, use method to close supplementary provider processes that are launched during init.
2026-05-14 08:24:11 -04:00
Daniel Banck
7ac3e2ec19 Return SafeInitActionNotRelevant on empty config 2026-05-13 08:17:40 +02:00
Daniel Banck
94a640a1a5 Add test case for variable value without config 2026-05-13 08:17:40 +02:00
Daniel Banck
74084a7705 Return early during provider installation if there is no config 2026-05-13 08:17:40 +02:00
Sarah French
7a960db553
PSS: Add interactive confirmation of state storage provider trust when initialising a state store for the first time (#38395)
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
* refactor: Replace use of prepareInstallerEvents method. This will allow finer control of callbacks when implementing security related features

* feat: Users are prompted to approve a provider used for PSS on first use, and only if downloaded via HTTP.

Prompts include signer details and key ID data.

* test: Users see "Authentication: unauthenticated" in prompt if network mirror doesn't include hashes

They'll see authentication data in all other prompt scenarios. There's no auth when using an fs mirror, but when those are in use we trust the providers already and no prompts are raised.

* refactor: Simplify how we prepare installation event callbacks by defining reused callbacks

* refactor: Remove unused parameters from `getProvidersFromState`
2026-05-12 10:42:26 -04:00
Radek Simko
badc70c93d
command/output: Ignore warnings in JSON mode (#38530)
* command/output: Ignore warnings in JSON mode

* add changelog entry
2026-05-06 10:26:40 +01:00
Sarah French
6554bda227
refactor: Update workspace select and new subcommands to use the arguments package for parsing arguments and flags (#38430)
Some checks failed
build / Build for freebsd_amd64 (push) Has been cancelled
build / Build for linux_amd64 (push) Has been cancelled
build / Build for openbsd_amd64 (push) Has been cancelled
build / Build for solaris_amd64 (push) Has been cancelled
build / Build for windows_amd64 (push) Has been cancelled
build / Build for freebsd_arm (push) Has been cancelled
build / Build for linux_arm (push) Has been cancelled
build / Build for darwin_arm64 (push) Has been cancelled
build / Build for linux_arm64 (push) Has been cancelled
build / Build for windows_arm64 (push) Has been cancelled
build / Build Docker image for linux_386 (push) Has been cancelled
build / Build Docker image for linux_amd64 (push) Has been cancelled
build / Build Docker image for linux_arm (push) Has been cancelled
build / Build Docker image for linux_arm64 (push) Has been cancelled
build / Build e2etest for linux_386 (push) Has been cancelled
build / Build e2etest for windows_386 (push) Has been cancelled
build / Build e2etest for darwin_amd64 (push) Has been cancelled
build / Build e2etest for linux_amd64 (push) Has been cancelled
build / Build e2etest for windows_amd64 (push) Has been cancelled
build / Build e2etest for linux_arm (push) Has been cancelled
build / Build e2etest for darwin_arm64 (push) Has been cancelled
build / Build e2etest for linux_arm64 (push) Has been cancelled
build / Run e2e test for linux_386 (push) Has been cancelled
build / Run e2e test for windows_386 (push) Has been cancelled
build / Run e2e test for darwin_amd64 (push) Has been cancelled
build / Run e2e test for linux_amd64 (push) Has been cancelled
build / Run e2e test for windows_amd64 (push) Has been cancelled
build / Run e2e test for linux_arm (push) Has been cancelled
build / Run e2e test for linux_arm64 (push) Has been cancelled
build / Run terraform-exec test for linux amd64 (push) Has been cancelled
* refactor: Move method `ValidWorkspaceName` and related const into arguments package, update references

This function is primarily used to validate arguments, but it's used once (in (m *Meta) Workspace) in a different context, so I've left the original function signature in the command package.

* feat: Add `workspace new`-related code to arguments package

* refactor: Update `workspace new` to use the arguments package when parsing arguments

Note that this changes the format of errors returned when arg parsing fails - this is now wrapped in a diagnostic so now starts with `\nError: ` and has an extra trailing newline.

* feat: Add `workspace select`-related code to arguments package

* refactor: Update `workspace select` to use the arguments package when parsing arguments

Note that this changes the format of errors returned when arg parsing fails - this is now wrapped in a diagnostic so now starts with `\nError: ` and has an extra trailing newline.
2026-05-01 16:39:54 +01:00
Sarah French
dd35f66105
fix: warnings against using terraform env list are shown in JSON format when the -json flag is present (#38469) 2026-05-01 13:53:50 +01:00
Sarah French
559233329e
Fix: Re-enable using prerelease providers in the new two-step provider download in init (#38502)
* test: Add pre-release to available providers. Existing tests don't use it because the configuration doesn't specify the prerelease as the version constraint.

This was the gap in my understanding - prerelease providers are handled differently in the installer logic. I believe it boils down to this: 29863fd2ba/versions/set_released.go (L5-L7)

* test: Add failing tests that show expected behaviour when a pre-release of a provider is used

* fix: Ensure that any relevant version constraints from the config are available to use when installing providers present in the state

* test: Add test defining pre-release download behaviour that was present before v1.15

* test: Update test to reflect that 2 step init is no longer experimental or specific to the PSS project
2026-05-01 10:12:32 +00:00
Austin Valle
6428b2bdbc add provider source back to success tests 2026-04-30 16:07:32 -04:00
James Bardin
e480b016f8 remove the extra logic to detect prov funcs
We can't detect why a provider function is missing is all cases, so
get rid of the extra logic trying to do that.

We also admit here that we need to allow a provider function within a
variable validation condition, because that is not the only way these
could fail during init, and it's otherwise valid during the next phase.
2026-04-30 15:55:29 -04:00
James Bardin
c6b61bf731 simplify error messages for dynamic source
We can't fully detect why a module source or version might be unknown,
so instead use a simpler error that covers all possible reasons. If we
do find a way to get more specific in the future, we can extent it then,
but the current errors were trying to be specific when they couldn't.
2026-04-30 15:55:26 -04:00
Austin Valle
19972a4606 adjust tests 2026-04-30 15:32:30 -04:00
Austin Valle
1c88535ac0 add test for validation reference to non-const variable 2026-04-30 15:19:51 -04:00
Austin Valle
d2c9214081 prune validate nodes 2026-04-30 15:01:37 -04:00
Austin Valle
b8bdde09ca Merge branch 'main' into provider-defined-function-during-init 2026-04-30 12:27:58 -04:00
Sarah French
b7a43b31b0 Comments and changes from pairing
Co-authored-by: Austin Valle <austinvalle@gmail.com>
2026-04-30 15:08:33 +01:00
Radek Simko
e6850a514f
fix: Avoid warnings in terraform output -raw (#38487)
* command/output: Avoid warnings in '-raw' output

* command/output: Add regression test

Co-authored-by: Daniel Schmidt <danielmschmidt92@gmail.com>

* Add changelog entry

* Clarify changelog entry

---------

Co-authored-by: Daniel Schmidt <danielmschmidt92@gmail.com>
2026-04-30 11:58:39 +00:00
Austin Valle
b0539318f1 remove duplicate test 2026-04-29 17:33:44 -04:00
Austin Valle
6c783ce1be add some tests + TODOs 2026-04-29 17:32:08 -04:00
Sarah French
bb7491c368
Limit backend block validation in the validate command to just backend type (#38468)
* fix: Limit backend validation to just the backend type.

Also, remove similar validation for state stores, which would cause a similar issue in future.

* test: Add a new test showing behavior when removed backend types are in a config.
2026-04-29 18:34:42 +02:00
Sarah French
e24abdf6ff
refactor: Update workspace select and delete subcommands to use the arguments package for parsing arguments and flags (#38429)
* feat: Add `workspace show`-related code to arguments package

* refactor: Update `workspace show` to use the arguments package when parsing arguments

* refactor: Split code for workspace subcommands into separate files in arguments package

* refactor: Move code common to all workspace commands into separate file in arguments package

* feat: Add `workspace delete`-related code to arguments package

* refactor: Update `workspace delete` to use the arguments package when parsing arguments
2026-04-29 08:05:49 -04:00
Sarah French
1edd518394
test: Add test helper for mocking out use of a network mirror as a provider source (#38447)
* refactor: Add `NewMockHTTPMirrorSource` test helper. This required refactoring `NewMockHTTPMirrorSource` to pull out reused logic.

* refactor: Move structs defining expected HTTP responses from a network mirror into `getproviders` package

* feat: Add `newHTTPMirrorProviderSourceUsingTestHttpServer` test helper, for tests that need to include use of a network mirror when downloading providers.
2026-04-28 11:56:35 +01:00
UKEME BASSEY
027f94439b Merge remote-tracking branch 'origin/main' into show-info-when-resources-are-left-due-to-skip-cleanup 2026-04-27 11:53:39 -04:00
UKEME BASSEY
8219912d1b add changelog & updates 2026-04-27 11:51:12 -04:00
Radek Simko
69aa544660
command: Implement skeleton for state migrate (#38435)
* command: Implement skeleton for 'state migrate'

* address PR feedback
2026-04-27 16:39:02 +01:00
UKEME BASSEY
a3ce749dd5 add tests 2026-04-27 11:05:51 -04:00
UKEME BASSEY
c857888605 show info when resources are not destroyed due to skip_cleanup 2026-04-27 11:05:34 -04:00
Sarah French
650fd346aa
refactor: Separate concerns in mock provider sources logic, handle callbacks using t.Cleanup (#38446)
* refactor: Split temp file creation logic out of FakeInstallablePackageMeta & FakePackageMetaViaHTTP. Handle cleanup internally.

* refactor: Use 'Must' helpers in `newMockProviderSourceUsingTestHttpServer`

* refactor: Update tests using `newMockProviderSource` to not handle 'close' callback
2026-04-27 12:13:55 +01:00
Sarah French
844f216569
Add missing test for views.WorkspaceList (#38434)
Some checks failed
build / Build for freebsd_amd64 (push) Has been cancelled
build / Build for linux_amd64 (push) Has been cancelled
build / Build for openbsd_amd64 (push) Has been cancelled
build / Build for solaris_amd64 (push) Has been cancelled
build / Build for windows_amd64 (push) Has been cancelled
build / Build for freebsd_arm (push) Has been cancelled
build / Build for linux_arm (push) Has been cancelled
build / Build for darwin_arm64 (push) Has been cancelled
build / Build for linux_arm64 (push) Has been cancelled
build / Build for windows_arm64 (push) Has been cancelled
build / Build Docker image for linux_386 (push) Has been cancelled
build / Build Docker image for linux_amd64 (push) Has been cancelled
build / Build Docker image for linux_arm (push) Has been cancelled
build / Build Docker image for linux_arm64 (push) Has been cancelled
build / Build e2etest for linux_386 (push) Has been cancelled
build / Build e2etest for windows_386 (push) Has been cancelled
build / Build e2etest for darwin_amd64 (push) Has been cancelled
build / Build e2etest for linux_amd64 (push) Has been cancelled
build / Build e2etest for windows_amd64 (push) Has been cancelled
build / Build e2etest for linux_arm (push) Has been cancelled
build / Build e2etest for darwin_arm64 (push) Has been cancelled
build / Build e2etest for linux_arm64 (push) Has been cancelled
build / Run e2e test for linux_386 (push) Has been cancelled
build / Run e2e test for windows_386 (push) Has been cancelled
build / Run e2e test for darwin_amd64 (push) Has been cancelled
build / Run e2e test for linux_amd64 (push) Has been cancelled
build / Run e2e test for windows_amd64 (push) Has been cancelled
build / Run e2e test for linux_arm (push) Has been cancelled
build / Run e2e test for linux_arm64 (push) Has been cancelled
build / Run terraform-exec test for linux amd64 (push) Has been cancelled
* test: Add test for views.WorkspaceList
2026-04-24 11:54:24 +01:00
Sarah French
80a9d6b945
PSS: Prevent the state store provider being upgraded via the init command, unless the store is reconfigured (#38391)
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
* test: Move existing provider upgrade test into subtest, preparing for more subtests later

* feat: `init` command blocks upgrading the PSS provider

* test: Add test showing that upgrading non-state store providers isn't blocked as long as the state store provider is pinned in required_providers.

* feat: Upgrading the state store provider is possible during init, but it requires reconfiguring the state store.

* test: Revert change to shared test fixture, update -upgrade tests to create their own main.tf files.
2026-04-23 07:51:26 +01:00
Sarah French
2c125d7952
Make validation -json command produce JSON output when argument parsing raises an error
Some checks failed
build / Build for freebsd_amd64 (push) Has been cancelled
build / Build for linux_amd64 (push) Has been cancelled
build / Build for openbsd_amd64 (push) Has been cancelled
build / Build for solaris_amd64 (push) Has been cancelled
build / Build for windows_amd64 (push) Has been cancelled
build / Build for freebsd_arm (push) Has been cancelled
build / Build for linux_arm (push) Has been cancelled
build / Build for darwin_arm64 (push) Has been cancelled
build / Build for linux_arm64 (push) Has been cancelled
build / Build for windows_arm64 (push) Has been cancelled
build / Build Docker image for linux_386 (push) Has been cancelled
build / Build Docker image for linux_amd64 (push) Has been cancelled
build / Build Docker image for linux_arm (push) Has been cancelled
build / Build Docker image for linux_arm64 (push) Has been cancelled
build / Build e2etest for linux_386 (push) Has been cancelled
build / Build e2etest for windows_386 (push) Has been cancelled
build / Build e2etest for darwin_amd64 (push) Has been cancelled
build / Build e2etest for linux_amd64 (push) Has been cancelled
build / Build e2etest for windows_amd64 (push) Has been cancelled
build / Build e2etest for linux_arm (push) Has been cancelled
build / Build e2etest for darwin_arm64 (push) Has been cancelled
build / Build e2etest for linux_arm64 (push) Has been cancelled
build / Run e2e test for linux_386 (push) Has been cancelled
build / Run e2e test for windows_386 (push) Has been cancelled
build / Run e2e test for darwin_amd64 (push) Has been cancelled
build / Run e2e test for linux_amd64 (push) Has been cancelled
build / Run e2e test for windows_amd64 (push) Has been cancelled
build / Run e2e test for linux_arm (push) Has been cancelled
build / Run e2e test for linux_arm64 (push) Has been cancelled
build / Run terraform-exec test for linux amd64 (push) Has been cancelled
* refactor: Put existing test into subtest
* fix: Make `validation -json` command produce JSON output when argument parsing raises an error
2026-04-21 17:46:40 +01:00
Sarah French
7e3f57b40b
test: Update test helper newMockProviderSourceUsingTestHttpServer to be able to serve multiple providers and multiple provider versions (#38415)
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
* test: Update test helper `newMockProviderSourceUsingTestHttpServer` to be able to serve multiple providers and multiple provider versions.
2026-04-21 10:49:08 +02:00
Daniel Banck
7c828ce3c0 Add test case for validate JSON diags 2026-04-20 17:04:10 +02:00
Daniel Banck
50ac6cf0e3 Fix validate not returning JSON for early diagnostics
Errors during initializing the config loader and collecting variable
values were printed as human readable message even if `-json` was
specified. This PR fixes this behavior and turns both errors into JSON.
2026-04-20 17:04:10 +02:00
Sarah French
694ed4a33d
Add machine-readable JSON output to the workspace list command (#38397)
* feat: Add `-json` flag to the `workspace list` command

* feat: Implement JSON view for `workspace list`, connect to -json flag, add tests defining new command output

* Add change file

* Address reviewer feedback
2026-04-20 11:36:24 +01:00
Daniel Banck
7554bda28e Fix fmt for .tfquery.hcl files
Formatting support for these files was still gated behind an
experimental flag. This PR removes the flag and enables query file
formatting by default.
2026-04-17 16:09:06 +02:00
Sarah French
b4c5234c98
chore: Remove unused DefaultWorkspaceCreatedMessage and defaultWorkspaceCreatedInfo (#38394)
These should have been removed as part of https://github.com/hashicorp/terraform/pull/38281
2026-04-17 10:47:18 +02:00
Sarah French
c975e0cd78
Refactor workspace list human output to use a views-like architecture, so adding JSON output is possible without breaking changes (#38392)
* test: Add a test that asserts human output from workspace commands with colour enabled or disabled

* refactor: Update `workspace list` to use cli.Ui in a Views-like way for human output. Update how output is returned by the command to use a single List method.

* refactor: Make `workspace list` command parse its arguments using the `arguments` package

* refactor: Replace use of `ModulePath` with ` c.WorkingDir.RootModuleDir()` to separate concerns

* test: Update tests that feature the `workspace list` command to include a WorkingDir value.

This is necessary after the changes in b32b60f6a7

* feat: Detect unexpected arguments and flags using the arguments package.

* refactor: Remove duplicate call to c.View.Configure, add code comments explaining code.

* fix: Make sure argument parsing errors are handled as soon as the view is usable.

* test: Update TestWorkspace_extraArgError to account for new validation via the arguments package

* fix: Update outdated copyright headers

* test: Update test name

* refactor: Reintroduce the old behaviour when unexpected positional arguments were present by using a specific ParseWorkspaceList method
2026-04-16 16:25:12 +01:00
Sarah French
a28750d8d1
PSS: Remove handling of state migrations including PSS from the init command (#38388)
* feat: Any state migration situations involving PSS are now resolved through init -reconfigure or the new state migrate command.

Also, remove methods and structs that aren't used anymore: stateStore_to_backend, backend_to_stateStore, stateStore_changed, removeLocalState, errStateStoreClearSaved

* test: Fix test log contents to reference correct test name

* fix: Make sure that errStateStoreInitDiag suggests `init` when the store is uninitialised, and suggest `state migrate` + `init -reconfigure` when a migration is needed

* fix: Make errBackendToStateStoreInitDiag suggest the correct commands for a state migration.

* fix: Standardise on "run <command>" over "use <command>" in error messages

* test: Update tests about handling changes in a state store's configuration.

We need to re-implement these tests in the context of testing a new `state migrate` command

* test: Remove test about handling provider updates in the context of PSS.

We need to re-implement this test in the context of testing a new `state migrate` command with an `-upgrade` flag. We also need to implement behaviour in `init` that blocks upgrading the PSS provider.

* test: Update test where `init` detects a `state_store` block is removed.

* test: Update test where `init` detects a migration from state_store to backend

* test: Update test where `init` detects a migration from backend to state_store

* test: Update test where `init` detects a migration from the cloud backend to state_store

* test: Update E2E test error message assertions to match recent changes
2026-04-16 11:28:05 +01:00
Sarah French
c05eaaf20d
PSS: Refactor how we handle unmanaged providers, add support for using dev_override (#38269)
Some checks failed
build / Build for freebsd_amd64 (push) Has been cancelled
build / Build for linux_amd64 (push) Has been cancelled
build / Build for openbsd_amd64 (push) Has been cancelled
build / Build for solaris_amd64 (push) Has been cancelled
build / Build for windows_amd64 (push) Has been cancelled
build / Build for freebsd_arm (push) Has been cancelled
build / Build for linux_arm (push) Has been cancelled
build / Build for darwin_arm64 (push) Has been cancelled
build / Build for linux_arm64 (push) Has been cancelled
build / Build for windows_arm64 (push) Has been cancelled
build / Build Docker image for linux_386 (push) Has been cancelled
build / Build Docker image for linux_amd64 (push) Has been cancelled
build / Build Docker image for linux_arm (push) Has been cancelled
build / Build Docker image for linux_arm64 (push) Has been cancelled
build / Build e2etest for linux_386 (push) Has been cancelled
build / Build e2etest for windows_386 (push) Has been cancelled
build / Build e2etest for darwin_amd64 (push) Has been cancelled
build / Build e2etest for linux_amd64 (push) Has been cancelled
build / Build e2etest for windows_amd64 (push) Has been cancelled
build / Build e2etest for linux_arm (push) Has been cancelled
build / Build e2etest for darwin_arm64 (push) Has been cancelled
build / Build e2etest for linux_arm64 (push) Has been cancelled
build / Run e2e test for linux_386 (push) Has been cancelled
build / Run e2e test for windows_386 (push) Has been cancelled
build / Run e2e test for darwin_amd64 (push) Has been cancelled
build / Run e2e test for linux_amd64 (push) Has been cancelled
build / Run e2e test for windows_amd64 (push) Has been cancelled
build / Run e2e test for linux_arm (push) Has been cancelled
build / Run e2e test for linux_arm64 (push) Has been cancelled
build / Run terraform-exec test for linux amd64 (push) Has been cancelled
* feat: Enable use of developer override providers when using PSS

* feat: Store how a provider was supplied to Terraform in the backend state file. This allows triggering a prompt for state migration if there's a change between using a managed provider versus an unmanaged/override provider.

* test: Update all PSS-related backend state files in test fixtures to include new, necessary provider_supply_mode data.

* fix: Avoid duplicate dev_override warnings

* refactor: Change how we determine how a provider is supplied to Terraform. By using supply mode data we prevent multiple parts of the code checking if a given provider is reattached/builtin/etc...

* test: Add separate tests showing a built-in or dev override provider being used for the main workflow using PSS

* test: Add E2E tests that characterise current behaviour when how a provider is supplied is changed partway through different workflows

* fix: Tolerate missing default workspace when using PSS and init handles minor changes in state store configuration.

* feat: `init`-related code will prompt a user to migrate state if Terraform detects a swap between managed and unmanaged providers being used for PSS.

Internally, what happens is the different version data (null versus a value being present) impacts the hash of the state store. This then triggers logic where TF checks if a migration is needed or if the new hash value should be silently updated in the backend state file. We always prompt for migration.

* refactor: Add `NotManagedByTerraform` method to `ProviderSupplyMode`

* Apply suggestions from code review

Co-authored-by: Radek Simko <radeksimko@users.noreply.github.com>

---------

Co-authored-by: Radek Simko <radeksimko@users.noreply.github.com>
2026-04-14 15:07:56 +01:00
Kristin Laemmert
002476034a
feat(cli): add -json flag for state show (#38341)
adds json output for state show. The output is modeled after Validate's json output, which includes any diagnostics as part of the json response (instead of returning non-json errors) once the view is configured.
2026-04-14 09:33:23 -04:00
Sarah French
ae14dc3ea8
refactor: Stop workspace new, show, and select commands using ModulePath method to determine the working directory (#38358)
* test: Add test defining how workspace subcommands react to unexpected arguments.

* refactor: Update `workspace new` and `select` commands to access the config path using `c.WorkingDir.RootModuleDir()`

* refactor: Update `workspace delete` command to access the config path using `c.WorkingDir.RootModuleDir()`

This results in test failures because the delete command's implementation doesn't indirectly invoke the (Meta).fixupMissingWorkingDir method. Other workspace subcommands do invoke the fixup method via calling (Meta).Workspace, which causes (Meta).DataDir to be invoked, which invokes the fixup.

* tests: Update all workspace tests to include a `WorkingDir` value in the `Meta`.

Prior to this change some commands would fixup this missing data, and depending on whether the meta was reused or not that would impact testing other commands. Commands that tested only the delete command would fail due to a missing workspace due to this.
2026-04-08 12:02:55 -04:00
Daniel Banck
f29046037f Add regression test for apply with vars
Running an apply from a plan should not raise diagnostics for missing
variables. All non-ephemeral variables are already available in the
planfile.
2026-03-31 16:16:58 +02:00