cli: Fix nested single and map diff rendering

Indentation was out by two spaces. This is now consistent with the other
displays of object/map values: four spaces for each nesting level.
This commit is contained in:
Alisdair McDiarmid 2021-11-19 15:19:08 -05:00
parent ec3058d551
commit a8b9d086b2
2 changed files with 36 additions and 36 deletions

View File

@ -461,10 +461,10 @@ func (p *blockBodyDiffPrinter) writeNestedAttrDiff(
if action != plans.NoOp && (p.pathForcesNewResource(path) || p.pathForcesNewResource(path[:len(path)-1])) { if action != plans.NoOp && (p.pathForcesNewResource(path) || p.pathForcesNewResource(path[:len(path)-1])) {
p.buf.WriteString(p.color.Color(forcesNewResourceCaption)) p.buf.WriteString(p.color.Color(forcesNewResourceCaption))
} }
p.writeAttrsDiff(objS.Attributes, old, new, indent+2, path, result) p.writeAttrsDiff(objS.Attributes, old, new, indent+4, path, result)
p.writeSkippedAttr(result.skippedAttributes, indent+4) p.writeSkippedAttr(result.skippedAttributes, indent+6)
p.buf.WriteString("\n") p.buf.WriteString("\n")
p.buf.WriteString(strings.Repeat(" ", indent)) p.buf.WriteString(strings.Repeat(" ", indent+2))
p.buf.WriteString("}") p.buf.WriteString("}")
case configschema.NestingList: case configschema.NestingList:
@ -690,15 +690,15 @@ func (p *blockBodyDiffPrinter) writeNestedAttrDiff(
} }
path := append(path, cty.IndexStep{Key: cty.StringVal(k)}) path := append(path, cty.IndexStep{Key: cty.StringVal(k)})
p.writeAttrsDiff(objS.Attributes, oldValue, newValue, indent+6, path, result) p.writeAttrsDiff(objS.Attributes, oldValue, newValue, indent+8, path, result)
p.writeSkippedAttr(result.skippedAttributes, indent+8) p.writeSkippedAttr(result.skippedAttributes, indent+10)
p.buf.WriteString("\n") p.buf.WriteString("\n")
p.buf.WriteString(strings.Repeat(" ", indent+4)) p.buf.WriteString(strings.Repeat(" ", indent+6))
p.buf.WriteString("},\n") p.buf.WriteString("},\n")
} }
} }
p.writeSkippedElems(unchanged, indent+4) p.writeSkippedElems(unchanged, indent+6)
p.buf.WriteString(strings.Repeat(" ", indent+2)) p.buf.WriteString(strings.Repeat(" ", indent+2))
p.buf.WriteString("}") p.buf.WriteString("}")
if !new.IsKnown() { if !new.IsKnown() {

View File

@ -354,9 +354,9 @@ new line
ExpectedOutput: ` # test_instance.example will be created ExpectedOutput: ` # test_instance.example will be created
+ resource "test_instance" "example" { + resource "test_instance" "example" {
+ conn_info = { + conn_info = {
+ password = (sensitive value) + password = (sensitive value)
+ user = "not-secret" + user = "not-secret"
} }
+ id = (known after apply) + id = (known after apply)
+ password = (sensitive value) + password = (sensitive value)
} }
@ -3179,8 +3179,8 @@ func TestResourceChange_nestedMap(t *testing.T) {
+ ami = "ami-AFTER" + ami = "ami-AFTER"
+ disks = { + disks = {
+ "disk_a" = { + "disk_a" = {
+ mount_point = "/var/diska" + mount_point = "/var/diska"
}, },
} }
+ id = "i-02ae66f368e8518a9" + id = "i-02ae66f368e8518a9"
@ -3226,8 +3226,8 @@ func TestResourceChange_nestedMap(t *testing.T) {
~ ami = "ami-BEFORE" -> "ami-AFTER" ~ ami = "ami-BEFORE" -> "ami-AFTER"
~ disks = { ~ disks = {
+ "disk_a" = { + "disk_a" = {
+ mount_point = "/var/diska" + mount_point = "/var/diska"
}, },
} }
id = "i-02ae66f368e8518a9" id = "i-02ae66f368e8518a9"
@ -3279,9 +3279,9 @@ func TestResourceChange_nestedMap(t *testing.T) {
~ ami = "ami-BEFORE" -> "ami-AFTER" ~ ami = "ami-BEFORE" -> "ami-AFTER"
~ disks = { ~ disks = {
~ "disk_a" = { ~ "disk_a" = {
+ size = "50GB" + size = "50GB"
# (1 unchanged attribute hidden) # (1 unchanged attribute hidden)
}, },
} }
id = "i-02ae66f368e8518a9" id = "i-02ae66f368e8518a9"
@ -3342,10 +3342,10 @@ func TestResourceChange_nestedMap(t *testing.T) {
~ ami = "ami-BEFORE" -> "ami-AFTER" ~ ami = "ami-BEFORE" -> "ami-AFTER"
~ disks = { ~ disks = {
+ "disk_2" = { + "disk_2" = {
+ mount_point = "/var/disk2" + mount_point = "/var/disk2"
+ size = "50GB" + size = "50GB"
}, },
# (1 unchanged element hidden) # (1 unchanged element hidden)
} }
id = "i-02ae66f368e8518a9" id = "i-02ae66f368e8518a9"
@ -3409,9 +3409,9 @@ func TestResourceChange_nestedMap(t *testing.T) {
~ ami = "ami-BEFORE" -> "ami-AFTER" ~ ami = "ami-BEFORE" -> "ami-AFTER"
~ disks = { ~ disks = {
~ "disk_a" = { # forces replacement ~ "disk_a" = { # forces replacement
~ size = "50GB" -> "100GB" ~ size = "50GB" -> "100GB"
# (1 unchanged attribute hidden) # (1 unchanged attribute hidden)
}, },
} }
id = "i-02ae66f368e8518a9" id = "i-02ae66f368e8518a9"
@ -3460,9 +3460,9 @@ func TestResourceChange_nestedMap(t *testing.T) {
~ ami = "ami-BEFORE" -> "ami-AFTER" ~ ami = "ami-BEFORE" -> "ami-AFTER"
~ disks = { ~ disks = {
- "disk_a" = { - "disk_a" = {
- mount_point = "/var/diska" -> null - mount_point = "/var/diska" -> null
- size = "50GB" -> null - size = "50GB" -> null
}, },
} }
id = "i-02ae66f368e8518a9" id = "i-02ae66f368e8518a9"
@ -3513,9 +3513,9 @@ func TestResourceChange_nestedMap(t *testing.T) {
~ ami = "ami-BEFORE" -> "ami-AFTER" ~ ami = "ami-BEFORE" -> "ami-AFTER"
~ disks = { ~ disks = {
- "disk_a" = { - "disk_a" = {
- mount_point = "/var/diska" -> null - mount_point = "/var/diska" -> null
- size = "50GB" -> null - size = "50GB" -> null
}, },
} -> (known after apply) } -> (known after apply)
id = "i-02ae66f368e8518a9" id = "i-02ae66f368e8518a9"
@ -3572,9 +3572,9 @@ func TestResourceChange_nestedMap(t *testing.T) {
~ ami = "ami-BEFORE" -> "ami-AFTER" ~ ami = "ami-BEFORE" -> "ami-AFTER"
~ disks = { ~ disks = {
+ "disk_a" = { + "disk_a" = {
+ mount_point = (sensitive) + mount_point = (sensitive)
+ size = "50GB" + size = "50GB"
}, },
} }
id = "i-02ae66f368e8518a9" id = "i-02ae66f368e8518a9"
@ -4742,9 +4742,9 @@ func TestResourceChange_sensitiveVariable(t *testing.T) {
ExpectedOutput: ` # test_instance.example must be replaced ExpectedOutput: ` # test_instance.example must be replaced
-/+ resource "test_instance" "example" { -/+ resource "test_instance" "example" {
~ conn_info = { # forces replacement ~ conn_info = { # forces replacement
~ password = (sensitive value) ~ password = (sensitive value)
# (1 unchanged attribute hidden) # (1 unchanged attribute hidden)
} }
id = "i-02ae66f368e8518a9" id = "i-02ae66f368e8518a9"
} }
`, `,