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.
This commit is contained in:
parent
5d27a5b3e2
commit
bfee4b0295
|
@ -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,6 +136,7 @@ func formatPlanModuleExpand(
|
|||
newResource = opts.Color.Color(" [red](forces new resource)")
|
||||
}
|
||||
|
||||
if oldValues {
|
||||
buf.WriteString(fmt.Sprintf(
|
||||
" %s:%s %#v => %#v%s\n",
|
||||
attrK,
|
||||
|
@ -141,6 +144,14 @@ func formatPlanModuleExpand(
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue