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

Support long terraform variable names in ErrMissingVar #110

Merged
merged 2 commits into from
Nov 27, 2020

Conversation

c0sco
Copy link
Contributor

@c0sco c0sco commented Nov 19, 2020

An issue currently exists when a terraform variable with a very long name has no value. In these cases, the error message returned from tfexec/errors.go doesn't include the name of the terraform variable that is causing the problem. This is because terraform attempts to make error messages fit the terminal width, which means error messages can have a newline character instead of a space depending on the length of the variable name, and therefore the error message regex in terraform-exec doesn't match properly. This PR fixes this behavior to correctly display error messages no matter the length of the terraform variable name by matching on "\s" instead of " ".

This issue doesn't appear to be a problem with the Terraform 0.11 regex because of how much shorter the error message is.

To illustrate the problem, you can see the output when running the e2etest added in this PR without the fix to the regex in errors.go being in place:

errors_test.go:74: expected missing no_default_really_long_variable_name_that_will_line_wrap_tf_output, got ""

Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

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

LGTM, but I'll leave the decision with @kmoe as she has far more context here.

Copy link
Member

@kmoe kmoe left a comment

Choose a reason for hiding this comment

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

Thanks, good fix!

@kmoe kmoe merged commit 563fa8b into hashicorp:master Nov 27, 2020
@c0sco c0sco deleted the missing-long-var-name branch November 27, 2020 20:12
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.

3 participants