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

(Feature) Support terraform.workspace variable #181

Conversation

Stretch96
Copy link
Contributor

@Stretch96
Copy link
Contributor Author

Currently this just blindly sets TerraformWorkspace to default.

Ideally this would actually set it's value from the terraform workspace show output, but unsure of how to go about that. Also should decide whether it should only set it if deep check is enabled (--deep)

@wata727
Copy link
Member

wata727 commented Apr 23, 2018

Thanks for your contribution!

Ideally this would actually set it's value from the terraform workspace show output, but unsure of how to go about that. Also should decide whether it should only set it if deep check is enabled

I guess it will behave similarly to TerraformEnv. Since the current environment is stored in .terraform/environment, TerraformWorkspace also should refer to this.
https://github.com/wata727/tflint/blob/30023dbfbdaf3a15feb28453cefcec4c6c8d196b/config/config.go#L38-L40

@Stretch96
Copy link
Contributor Author

Ah yes, I'll add that to the PR 👍

* Using ${terraform.workspace} currently causes `tflint` to fail:
`unknown variable accessed: terraform.workspace in terraform.tf`
* Resolves terraform-linters#177
@Stretch96 Stretch96 force-pushed the feature/support-terraform-workspace-variable branch from 39b20d6 to d0d20e6 Compare April 24, 2018 10:16
@Stretch96
Copy link
Contributor Author

@wata727 That's added to the PR now 👍

@@ -25,6 +25,10 @@ func NewEvaluator(templates map[string]*hclast.File, schema []*schema.Template,
Type: hilast.TypeString,
Value: c.TerraformEnv,
}
varMap["terraform.workspace"] = hilast.Variable{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep sure, I'll add that in soon 😬

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready for review 👍

@Stretch96 Stretch96 force-pushed the feature/support-terraform-workspace-variable branch from e4bf19c to 2ee8232 Compare April 27, 2018 11:30
@wata727 wata727 merged commit d1ecc49 into terraform-linters:master Apr 28, 2018
@wata727
Copy link
Member

wata727 commented Apr 28, 2018

👍

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

Successfully merging this pull request may close these issues.

None yet

2 participants