hcl/printer: clear trailing newline from heredoc

This commit is contained in:
Mitchell Hashimoto 2015-11-10 15:02:21 -08:00
parent 16dcdb88fa
commit 7b107c7b54
3 changed files with 5 additions and 4 deletions

View File

@ -319,6 +319,7 @@ func (p *printer) objectType(o *ast.ObjectType) []byte {
// If the value is a heredoc, we "poison" it so that we can
// clean it up later. Heredocs don't indent their fields.
if lit, ok := item.Val.(*ast.LiteralType); ok && lit.Token.Type == token.HEREDOC {
val = val[:len(val)-1]
val = p.heredocIndent(val)
}

View File

@ -37,7 +37,6 @@ resource aws_instance "web" {
description = <<EOF
ANOTHER NETWORK INTERFACE
EOF
}
}
@ -52,5 +51,4 @@ output "web_ip" {
value = <<EOF
TUBES
EOF
}

View File

@ -331,7 +331,9 @@ func TestRealExample(t *testing.T) {
network_interface {
device_index = 0
description = "Main network interface"
description = <<EOF
Main interface
EOF
}
}`
@ -389,7 +391,7 @@ func TestRealExample(t *testing.T) {
{token.NUMBER, `0`},
{token.IDENT, `description`},
{token.ASSIGN, `=`},
{token.STRING, `"Main network interface"`},
{token.HEREDOC, "<<EOF\nMain interface\nEOF\n"},
{token.RBRACE, `}`},
{token.RBRACE, `}`},
{token.EOF, ``},