From bfee4b02958e536cee811a835090a8c82b2d89eb Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Sun, 8 May 2016 00:03:41 -0700 Subject: [PATCH] command: don't show old values for create diffs in plan New resources logically don't have "old values" for their attributes, so showing them as updates from the empty string is misleading and confusing. Instead, we'll skip showing the old value in a creation diff. --- command/format_plan.go | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/command/format_plan.go b/command/format_plan.go index daf3f60aa..84f7d89e7 100644 --- a/command/format_plan.go +++ b/command/format_plan.go @@ -87,6 +87,7 @@ func formatPlanModuleExpand( // resource header. color := "yellow" symbol := "~" + oldValues := true switch rdiff.ChangeType() { case terraform.DiffDestroyCreate: color = "green" @@ -94,6 +95,7 @@ func formatPlanModuleExpand( case terraform.DiffCreate: color = "green" symbol = "+" + oldValues = false case terraform.DiffDestroy: color = "red" symbol = "-" @@ -134,13 +136,22 @@ func formatPlanModuleExpand( newResource = opts.Color.Color(" [red](forces new resource)") } - buf.WriteString(fmt.Sprintf( - " %s:%s %#v => %#v%s\n", - attrK, - strings.Repeat(" ", keyLen-len(attrK)), - attrDiff.Old, - v, - newResource)) + if oldValues { + buf.WriteString(fmt.Sprintf( + " %s:%s %#v => %#v%s\n", + attrK, + strings.Repeat(" ", keyLen-len(attrK)), + attrDiff.Old, + v, + newResource)) + } else { + buf.WriteString(fmt.Sprintf( + " %s:%s %#v%s\n", + attrK, + strings.Repeat(" ", keyLen-len(attrK)), + v, + newResource)) + } } // Write the reset color so we don't overload the user's terminal