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

tflint: Add workaround when parsing a config that has a trailing heredoc #128

Merged
merged 1 commit into from
Jul 17, 2021

Conversation

wata727
Copy link
Member

@wata727 wata727 commented Jul 17, 2021

Fixes #127
See also #93

If a plugin block ends with a heredoc (e.g. signing_key), the heredoc will not contain a trailing newline when the plugin side process parses the configuration. This does not meet the grammar of the heredoc and results in an "Unterminated template string" error.

As with #93, Unmarshal always adds a trailing newline when parsing the body. However, this is a pretty bad workaround. The biggest difference from #93 is that the added newline is meaningful. When parsing an expression, newlines are always ignored and do not affect the final parsed result, but when parsing a body the number of newlines does affect the result. For example:

plugin "aws" {
  foo = "bar"
  bar = "baz"
}

The above will be parsed as the following:

plugin "aws" {
  foo = "bar"
  bar = "baz"

}

This can have a strange effect on the display of the number of lines. However, the number of lines in a config file is only displayed when occurs a parse error mainly, so I will ignore this problem and fix the bug here.

@wata727 wata727 merged commit 6e3d918 into master Jul 17, 2021
@wata727 wata727 deleted the workaround_for_parsing_trailing_heredoc_body branch July 17, 2021 08:49
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.

signing_key attribute works during --init but not during tflint
1 participant