From b562c4fb84922d1e802a6cb2c7ff1b60a8c10031 Mon Sep 17 00:00:00 2001 From: Alisdair McDiarmid Date: Fri, 19 Nov 2021 13:06:34 -0500 Subject: [PATCH] cli: Fix nested set diff rendering indentation --- internal/command/format/diff.go | 6 ++-- internal/command/format/diff_test.go | 46 ++++++++++++++-------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/internal/command/format/diff.go b/internal/command/format/diff.go index b8e97c7c7..0179bb2d7 100644 --- a/internal/command/format/diff.go +++ b/internal/command/format/diff.go @@ -615,14 +615,14 @@ func (p *blockBodyDiffPrinter) writeNestedAttrDiff( } path := append(path, cty.IndexStep{Key: val}) - p.writeAttrsDiff(objS.Attributes, oldValue, newValue, indent+6, path, result) + p.writeAttrsDiff(objS.Attributes, oldValue, newValue, indent+8, path, result) p.buf.WriteString("\n") - p.buf.WriteString(strings.Repeat(" ", indent+4)) + p.buf.WriteString(strings.Repeat(" ", indent+6)) p.buf.WriteString("},") } p.buf.WriteString("\n") - p.writeSkippedElems(unchanged, indent+4) + p.writeSkippedElems(unchanged, indent+6) p.buf.WriteString(strings.Repeat(" ", indent+2)) p.buf.WriteString("]") diff --git a/internal/command/format/diff_test.go b/internal/command/format/diff_test.go index fd7f16163..79ef60ff8 100644 --- a/internal/command/format/diff_test.go +++ b/internal/command/format/diff_test.go @@ -2800,8 +2800,8 @@ func TestResourceChange_nestedSet(t *testing.T) { ~ ami = "ami-BEFORE" -> "ami-AFTER" ~ disks = [ + { - + mount_point = "/var/diska" - }, + + mount_point = "/var/diska" + }, ] id = "i-02ae66f368e8518a9" @@ -2861,13 +2861,13 @@ func TestResourceChange_nestedSet(t *testing.T) { ~ ami = "ami-BEFORE" -> "ami-AFTER" ~ disks = [ + { - + mount_point = "/var/diska" - + size = "50GB" - }, + + mount_point = "/var/diska" + + size = "50GB" + }, - { - - mount_point = "/var/diska" -> null - }, - # (1 unchanged element hidden) + - mount_point = "/var/diska" -> null + }, + # (1 unchanged element hidden) ] id = "i-02ae66f368e8518a9" @@ -2925,13 +2925,13 @@ func TestResourceChange_nestedSet(t *testing.T) { ~ ami = "ami-BEFORE" -> "ami-AFTER" ~ disks = [ - { # forces replacement - - mount_point = "/var/diska" -> null - - size = "50GB" -> null - }, + - mount_point = "/var/diska" -> null + - size = "50GB" -> null + }, + { # forces replacement - + mount_point = "/var/diskb" - + size = "50GB" - }, + + mount_point = "/var/diskb" + + size = "50GB" + }, ] id = "i-02ae66f368e8518a9" @@ -2982,9 +2982,9 @@ func TestResourceChange_nestedSet(t *testing.T) { ~ ami = "ami-BEFORE" -> "ami-AFTER" ~ disks = [ - { - - mount_point = "/var/diska" -> null - - size = "50GB" -> null - }, + - mount_point = "/var/diska" -> null + - size = "50GB" -> null + }, ] id = "i-02ae66f368e8518a9" @@ -3071,9 +3071,9 @@ func TestResourceChange_nestedSet(t *testing.T) { ~ ami = "ami-BEFORE" -> "ami-AFTER" + disks = [ + { - + mount_point = "/var/diska" - + size = "50GB" - }, + + mount_point = "/var/diska" + + size = "50GB" + }, ] id = "i-02ae66f368e8518a9" @@ -3127,9 +3127,9 @@ func TestResourceChange_nestedSet(t *testing.T) { ~ ami = "ami-BEFORE" -> "ami-AFTER" ~ disks = [ - { - - mount_point = "/var/diska" -> null - - size = "50GB" -> null - }, + - mount_point = "/var/diska" -> null + - size = "50GB" -> null + }, ] -> (known after apply) id = "i-02ae66f368e8518a9"