Commit graph

101 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
2dbb7d9c05
PSS: Remove automatic creation of the default workspace's state file during init (#38281)
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: Stop Terraform creating the default workspace during init when using PSS

This is part of reconciling how in the past backends always reported that the default backend existed, even when it didn't. We want state stores to report reality only, so we need to let Terraform handle the discrepancy. Prior to this commit we handled it by making reality match the old lie that the default workspace always exists. After this commit we're just embracing Terraform working with truthful information.
2026-03-19 15:47:29 +00:00
Daniel Banck
0fa9e5b4da command: Add vars to get command (and refactor it) 2026-03-17 16:41:28 +01:00
Daniel Banck
cdbd4f17f2 command: Add vars to taint command 2026-03-17 16:41:28 +01:00
Daniel Banck
a836cd610d command: Add vars to state rm command 2026-03-17 16:41:28 +01:00
Daniel Banck
2115032765 command: Add vars to state replace command 2026-03-17 16:41:28 +01:00
Daniel Banck
36b26535b9 command: Add vars to state push command 2026-03-17 16:41:28 +01:00
Daniel Banck
aac8834600 command: Add vars to state pull command 2026-03-17 16:41:28 +01:00
Daniel Banck
b2a5ce8af1 command: Add vars to state mv command 2026-03-17 16:41:28 +01:00
Daniel Banck
c28c6c6d64 command: Add vars to providers schema command 2026-03-17 16:41:28 +01:00
Daniel Banck
ed2bdf6825 command: Add vars to providers mirror command 2026-03-17 16:41:28 +01:00
Daniel Banck
6c6be5bcfa command: Add vars to pvoiders lock command 2026-03-17 16:41:28 +01:00
Daniel Banck
1cc8345926 command: Add vars to providers command 2026-03-17 16:41:28 +01:00
Daniel Banck
c9e1b3a47b command: Add vars to modules command 2026-03-17 16:41:28 +01:00
Daniel Banck
a1c74c7d4e command: Add vars to graph command 2026-03-17 16:41:28 +01:00
Daniel Banck
4b132a4879 command: Add vars to validate command 2026-03-17 16:41:28 +01:00
Daniel Banck
f9cfdf1ebe Refactoring: Modernize graph command to use arguments 2026-03-11 12:04:10 +01:00
Daniel Banck
5a70c424b3 Fix import and show command
This commit moves some code around to fix configuration loading during
the (legacy) import command. And add vars to the show command.
2026-03-04 11:45:59 +01:00
Daniel Schmidt
de068da2ab refactor addVarsFromFile to use return value 2026-02-18 12:47:12 +01:00
Daniel Schmidt
4e921a8eae move CollectValuesFromTests to arguments package
This keeps the CollectValues and CollectValuesFromTests implementations
together.
2026-02-18 12:47:12 +01:00
Daniel Schmidt
f6a3f271be refactor console command to use arguments 2026-02-18 12:47:12 +01:00
Daniel Schmidt
8faccde780 implement centralized variable collection 2026-02-18 12:47:12 +01:00
Daniel Schmidt
026c935961 move UnparsedVariableValue from backendrun to arguments
This prevents a cyclic dependency and also makes sense semantically.
The arguments package will collect the unparsed variable values and
the backendrun helpers will work to collect the values and transform
them into terraform.InputValue.
2026-02-18 12:47:12 +01:00
Daniel Schmidt
90eae782bf move vars handling into own file 2026-02-18 12:47:12 +01:00
Daniel Schmidt
81b328f924
update copyright headers 2026-02-17 15:56:24 +01:00
Daniel Schmidt
592d0fe4dd
don't explicitly specify defaults in argument parsing 2026-02-17 15:55:45 +01:00
Daniel Schmidt
5e51b831be
refactor state-replace-provider command argument parsing 2026-02-17 15:55:45 +01:00
Daniel Schmidt
32fb18572d
don't explicitly specify defaults in argument parsing 2026-02-17 15:55:45 +01:00
Daniel Schmidt
89bea5de5b
refactor state-rm command argument parsing 2026-02-17 15:55:45 +01:00
Daniel Schmidt
c66d0d72c1
don't explicitly specify defaults in argument parsing 2026-02-17 15:55:45 +01:00
Daniel Schmidt
442126553b
refactor state-push command argument parsing 2026-02-17 15:55:45 +01:00
Daniel Schmidt
b9f6f14003
don't explicitly specify defaults in argument parsing 2026-02-17 15:55:45 +01:00
Daniel Schmidt
9f3c282096
refactor state-mv command argument parsing 2026-02-17 15:55:45 +01:00
Daniel Schmidt
52bbc57c62
refactor state-pull command argument parsing 2026-02-17 15:55:45 +01:00
Daniel Schmidt
acb6ed3f22
don't explicitly specify defaults in argument parsing 2026-02-17 15:55:45 +01:00
Daniel Schmidt
f7cde006ff
refactor state-show command argument parsing 2026-02-17 15:55:45 +01:00
Daniel Schmidt
da74b59ea1
don't explicitly specify defaults in argument parsing 2026-02-17 15:55:45 +01:00
Daniel Schmidt
3dbfbe5dc9
refactor state-list command argument parsing 2026-02-17 15:55:45 +01:00
Daniel Schmidt
af7783eb62
refactor providers lock command argument parsing 2026-02-17 15:55:45 +01:00
Daniel Schmidt
c7729926fa
don't explicitly specify defaults in argument parsing 2026-02-17 15:55:45 +01:00
Daniel Schmidt
0066780049
refactor providers mirror command argument parsing 2026-02-17 15:55:36 +01:00
Daniel Schmidt
c15f0409ed
don't explicitly specify defaults in argument parsing 2026-02-17 15:55:36 +01:00
Daniel Schmidt
0c384e8cd8
refactor providers schema command argument parsing 2026-02-17 15:55:36 +01:00