* test: Add test demonstrating how the `workspace list` command behaves when no workspaces are reported from a pluggable state store.
This scenario isn't possible when using backends. See the code comment for the test for more information.
* feat: Make Terraform warn when no workspaces exist, including guidance to users for how to create the workspace.
This change is not a breaking change because all backends report that the "default" workspace always exists. This new warning can only be viewed in specific circumstances by users of pluggable state storage.
* Add tests defining what are valid workspace names
* Update workspace name validation to mark an empty string as not valid
* Add change file
* Add command-level test showing the "" workspace cannot be created or selected
* Update invalid name error text to include empty string as invalid.
Previously we would reject attempts to delete a workspace if its state
contained any resources at all, even if none of the resources had any
resource instance objects associated with it.
Nowadays there isn't any situation where the normal Terraform workflow
will leave behind resource husks, and so this isn't as problematic as it
might've been in the v0.12 era, but nonetheless what we actually care
about for this check is whether there might be any remote objects that
this state is tracking, and for that it's more precise to look for
non-nil resource instance objects, rather than whole resources.
This also includes some adjustments to our error messaging to give more
information about the problem and to use terminology more consistent with
how we currently talk about this situation in our documentation and
elsewhere in the UI.
We were also using the old State.HasResources method as part of some of
our tests. I considered preserving it to avoid changing the behavior of
those tests, but the new check seemed close enough to the intent of those
tests that it wasn't worth maintaining this method that wouldn't be used
in any main code anymore. I've therefore updated those tests to use
the new HasResourceInstanceObjects method instead.
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/workspace_command.go (Browse further)