hcl/printer: clear trailing newline from heredoc
This commit is contained in:
parent
16dcdb88fa
commit
7b107c7b54
@ -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
|
// If the value is a heredoc, we "poison" it so that we can
|
||||||
// clean it up later. Heredocs don't indent their fields.
|
// clean it up later. Heredocs don't indent their fields.
|
||||||
if lit, ok := item.Val.(*ast.LiteralType); ok && lit.Token.Type == token.HEREDOC {
|
if lit, ok := item.Val.(*ast.LiteralType); ok && lit.Token.Type == token.HEREDOC {
|
||||||
|
val = val[:len(val)-1]
|
||||||
val = p.heredocIndent(val)
|
val = p.heredocIndent(val)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
hcl/printer/testdata/complexhcl.golden
vendored
2
hcl/printer/testdata/complexhcl.golden
vendored
@ -37,7 +37,6 @@ resource aws_instance "web" {
|
|||||||
description = <<EOF
|
description = <<EOF
|
||||||
ANOTHER NETWORK INTERFACE
|
ANOTHER NETWORK INTERFACE
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,5 +51,4 @@ output "web_ip" {
|
|||||||
value = <<EOF
|
value = <<EOF
|
||||||
TUBES
|
TUBES
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
}
|
}
|
@ -331,7 +331,9 @@ func TestRealExample(t *testing.T) {
|
|||||||
|
|
||||||
network_interface {
|
network_interface {
|
||||||
device_index = 0
|
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.NUMBER, `0`},
|
||||||
{token.IDENT, `description`},
|
{token.IDENT, `description`},
|
||||||
{token.ASSIGN, `=`},
|
{token.ASSIGN, `=`},
|
||||||
{token.STRING, `"Main network interface"`},
|
{token.HEREDOC, "<<EOF\nMain interface\nEOF\n"},
|
||||||
{token.RBRACE, `}`},
|
{token.RBRACE, `}`},
|
||||||
{token.RBRACE, `}`},
|
{token.RBRACE, `}`},
|
||||||
{token.EOF, ``},
|
{token.EOF, ``},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user