Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape characters for workspace selection #403

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

aanogueira
Copy link

@aanogueira aanogueira commented Aug 24, 2023

This PR aims to fix workspace selection for cases where the namespace starts with special characters, such as -.

@hashicorp-cla
Copy link

hashicorp-cla commented Aug 24, 2023

CLA assistant check
All committers have signed the CLA.

@aanogueira aanogueira changed the title fix: escape workspace selection Escape characters for workspace selection Aug 24, 2023
@aanogueira
Copy link
Author

Could I please get some review?

@ferrastas
Copy link

@radeksimko @kmoe sorry to poke you directly, but I just saw that you have been recently approving and merging other PR.
We now need to use a fork of the library because of this tiny issue. 😓
Thanks!

@ferrastas
Copy link

Just a quick example:

 $ terraform workspace list
* -dev
  -org
  -stag

...

$ terraform workspace select -org
Usage: terraform [global options] workspace select NAME

  Select a different Terraform workspace.

Options:

    -or-create=false    Create the Terraform workspace if it doesn't exist.
Error parsing command-line flags: flag provided but not defined: -org

...

$ terraform workspace select -- -org
Switched to workspace "-org".

@bflad
Copy link
Contributor

bflad commented Mar 15, 2024

One of the challenges here is that human-readable outputs in Terraform are not protected by compatibility promises, so relying on the existing output might break in future versions.

There are some recent discussions/issues around this:

I think ideally, Terraform CLI would have an enhancement on the existing command, such as a -json flag, for machine-readable output. That output (and this library) would be protected from potentially unexpected changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants