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

Requesting machine-enumaratable workspace listing #34775

Open
LeBaronDeCharlus opened this issue Mar 6, 2024 · 1 comment
Open

Requesting machine-enumaratable workspace listing #34775

LeBaronDeCharlus opened this issue Mar 6, 2024 · 1 comment
Labels
enhancement new new issue not yet triaged

Comments

@LeBaronDeCharlus
Copy link

Terraform Version

Terraform v1.6.0
on linux_amd64

Your version of Terraform is out of date! The latest version
is 1.7.4. You can update by downloading from https://www.terraform.io/downloads.html

Use Cases

ENHANCEMENTS

This PR proposition updates the visual indicator for the current workspace in the workspace list command output.

The asterisk (*) has been replaced with a greater-than symbol (>) to denote the active workspace and prevent unwanted behavior from wildcard symbol.

This change is reflected in both the workspace command tests and the workspace list command implementation.

Current

When you call workspace list argument, you have an output with your current workspace selected with * symbol like this :

$ terraform workspace list
  * default

If you want to iterate over the output you will have an issue because of the wildcard.

$ for i in $(terraform workspace list) ; do echo -ne "$i" ; done
default main.tf api.tf modules README.md terraform.tfvars.example test.tfvars variables.tf default test

We can see here that during the iteration, the for made a echo * because of the wildcard and print the files in the current directory.

Attempted Solutions

Bypassing

To make it work, we have to add a sed command to remove the character.

for i in $(terraform workspace list | sed 's/*//g'); do echo "$i"; done
default

Proposal

Proposition

Replace * by > (or whatever character that is not a wildcard) so we can simply do :

for i in $(terraform workspace list) ; do echo -ne "$i" ; done
>
default

Now even if > char is present, we do not have unwanted behavior with wildcard substitution when piping.

That would be much more easier for shell programming (for eg) to parse output without bad surprise.

References

No response

@crw
Copy link
Collaborator

crw commented Mar 7, 2024

Thanks for your interest in this issue! This is just a reminder to please avoid "+1" comments, and to use the upvote mechanism (click or add the 👍 emoji to the original post) to indicate your support for this issue. This helps avoid notification spam for issues with high numbers of participants while enabling the maintainers to prioritize issues. Thanks again for the feedback!

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

No branches or pull requests

2 participants