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
|
||||
// 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)
|
||||
}
|
||||
|
||||
|
2
hcl/printer/testdata/complexhcl.golden
vendored
2
hcl/printer/testdata/complexhcl.golden
vendored
@ -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
|
||||
|
||||
}
|
@ -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, ``},
|
||||
|
Loading…
Reference in New Issue
Block a user