hcl/printer: output an equal sign only if we had one originally
This commit is contained in:
parent
3bac6be959
commit
b24dfd1bb1
@ -178,9 +178,11 @@ func (p *printer) objectItem(o *ast.ObjectItem) []byte {
|
||||
buf.WriteByte(blank)
|
||||
|
||||
// reach end of key
|
||||
if i == len(o.Keys)-1 && len(o.Keys) == 1 {
|
||||
buf.WriteString("=")
|
||||
buf.WriteByte(blank)
|
||||
if i == len(o.Keys)-1 {
|
||||
if o.Assign.IsValid() && len(o.Keys) == 1 {
|
||||
buf.WriteString("=")
|
||||
buf.WriteByte(blank)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
4
hcl/printer/testdata/comment.golden
vendored
4
hcl/printer/testdata/comment.golden
vendored
@ -23,7 +23,7 @@ numbers = [1, 2] // another line here
|
||||
variable = {
|
||||
description = "bar" # another yooo
|
||||
|
||||
foo = {
|
||||
foo {
|
||||
# Nested standalone
|
||||
|
||||
bar = "fatih"
|
||||
@ -31,6 +31,6 @@ variable = {
|
||||
}
|
||||
|
||||
// lead comment
|
||||
foo = {
|
||||
foo {
|
||||
bar = "fatih" // line comment 2
|
||||
} // line comment 3
|
2
hcl/printer/testdata/comment_aligned.golden
vendored
2
hcl/printer/testdata/comment_aligned.golden
vendored
@ -1,4 +1,4 @@
|
||||
aligned = {
|
||||
aligned {
|
||||
# We have some aligned items below
|
||||
foo = "fatih" # yoo1
|
||||
default = "bar" # yoo2
|
||||
|
@ -1,6 +1,6 @@
|
||||
// A standalone comment
|
||||
|
||||
aligned = {
|
||||
aligned {
|
||||
# Standalone 1
|
||||
|
||||
a = "bar" # yoo1
|
||||
|
7
hcl/printer/testdata/complexhcl.golden
vendored
7
hcl/printer/testdata/complexhcl.golden
vendored
@ -26,10 +26,15 @@ resource aws_instance "web" {
|
||||
"${aws_security_group.firewall.foo}",
|
||||
]
|
||||
|
||||
network_interface = {
|
||||
network_interface {
|
||||
device_index = 0
|
||||
description = "Main network interface"
|
||||
}
|
||||
|
||||
network_interface = {
|
||||
device_index = 1
|
||||
description = "Another network interface"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_instance" "db" {
|
||||
|
7
hcl/printer/testdata/complexhcl.input
vendored
7
hcl/printer/testdata/complexhcl.input
vendored
@ -24,11 +24,16 @@ resource "aws_security_group" "firewall" {
|
||||
"foo",
|
||||
"${aws_security_group.firewall.foo}"
|
||||
]
|
||||
|
||||
|
||||
network_interface {
|
||||
device_index = 0
|
||||
description = "Main network interface"
|
||||
}
|
||||
|
||||
network_interface = {
|
||||
device_index = 1
|
||||
description = "Another network interface"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_instance" "db" {
|
||||
|
Loading…
Reference in New Issue
Block a user