Skip to content

Commit

Permalink
tflint: Add workaround when parsing a config that has a trailing here…
Browse files Browse the repository at this point in the history
…doc (#128)
  • Loading branch information
wata727 authored Jul 17, 2021
1 parent 9f2a2fc commit 6e3d918
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tflint/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ type MarshalledConfig struct {

// Unmarshal converts intermediate representations into the Config object.
func (c *MarshalledConfig) Unmarshal() (*Config, error) {
file, diags := hclsyntax.ParseConfig(c.BodyBytes, c.BodyRange.Filename, c.BodyRange.Start)
// HACK: Always add a newline to avoid heredoc parse errors.
// @see https://github.com/hashicorp/hcl/issues/441
src := []byte(string(c.BodyBytes) + "\n")
file, diags := hclsyntax.ParseConfig(src, c.BodyRange.Filename, c.BodyRange.Start)
if diags.HasErrors() {
return nil, diags
}
Expand Down

0 comments on commit 6e3d918

Please sign in to comment.