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.
* 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.
* 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
* 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
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.
* 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.
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.