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

Do not set workspace if it is default. #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bigeasy
Copy link

@bigeasy bigeasy commented Sep 7, 2019

Terraform Cloud does not support workspaces. Running terraform.py with a Terraform Cloud backend produces the error 'workspaces not supported'.

With this commit we invoke the command to set the namespace with the -no-color option to receive a plain-text UTF-8 response without terminal color codes. If the stderr response is empty or 'workspaces not supported', we continue with program operation.

@nbering
Copy link
Owner

nbering commented Sep 7, 2019

Seems reasonable.

I was just thinking, as soon as I saw your PR title, that maybe workspace should default to None, and then skip setting workspace entirely, unless it is specified. That way if this error is encountered it can be fatal, as it probably should be.

@bigeasy
Copy link
Author

bigeasy commented Sep 9, 2019

That's fine too. Maybe have it default to an empty string, just in case someone has a workspace named None.

@nbering
Copy link
Owner

nbering commented Sep 9, 2019

Maybe have it default to an empty string, just in case someone has a workspace named None.

Ah. I probably wasn't clear enough there. I mean the special Python value, None. Not the string, "None". It's python's equivalent of nil, or null, used when there is no defined value.

@bigeasy
Copy link
Author

bigeasy commented Sep 15, 2019

Sounds good to me. Do you want me to have a go at making it that way?

@bigeasy
Copy link
Author

bigeasy commented Sep 15, 2019

Had a go. Seems to work. Python is not familiar to me, so please critique. If it looks good, I please let me squash commits before merging.

@nbering
Copy link
Owner

nbering commented Sep 15, 2019

Given a quick eyeball, looks correct to me. I'll give it a little manual test later today... but I think you can go ahead and do your squash if you like.

Terraform Cloud does not support workspaces when you specify a specific
workspace name. Running `terraform.py` with a Terraform Cloud backend
configured this way produces the error 'workspaces not supported'.

With this commit we only invoke the command to set the workspace if the
`TERRAFORM_WS_NAME` workspace environment variable is set.
@bigeasy
Copy link
Author

bigeasy commented Sep 19, 2019

Squashed. Thank you for writing this useful utility.

@nbering
Copy link
Owner

nbering commented Sep 20, 2019

I run this more or less as a weekend project. I'll get to merging in the next couple days.

Thanks for your contribution! 😄

@egadgetjnr
Copy link

@nbering Are we able to get this merged by chance? :)

I'm currently using the updated changes from @bigeasy and can confirm it works.

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