command: Remove stubbed-out apply diff output code

This code was made to do nothing pre-0.12, and we have no plans to
reintroduce a diff in the apply output, so it seems reasonable to now
remove it altogether.
This commit is contained in:
Alisdair McDiarmid 2020-07-22 14:19:00 -04:00
parent 5734a0c014
commit ee19b0d6c5
1 changed files with 1 additions and 51 deletions

View File

@ -4,7 +4,6 @@ import (
"bufio" "bufio"
"bytes" "bytes"
"fmt" "fmt"
"sort"
"strings" "strings"
"sync" "sync"
"time" "time"
@ -94,54 +93,6 @@ func (h *UiHook) PreApply(addr addrs.AbsResourceInstance, gen states.Generation,
return terraform.HookActionContinue, nil return terraform.HookActionContinue, nil
} }
attrBuf := new(bytes.Buffer)
// Get all the attributes that are changing, and sort them. Also
// determine the longest key so that we can align them all.
keyLen := 0
// FIXME: This is stubbed out in preparation for rewriting it to use
// a structural presentation rather than the old-style flatmap one.
// We just assume no attributes at all for now, pending new code to
// work with the two cty.Values we are given.
dAttrs := map[string]terraform.ResourceAttrDiff{}
keys := make([]string, 0, len(dAttrs))
for key, _ := range dAttrs {
keys = append(keys, key)
if len(key) > keyLen {
keyLen = len(key)
}
}
sort.Strings(keys)
// Go through and output each attribute
for _, attrK := range keys {
attrDiff := dAttrs[attrK]
v := attrDiff.New
u := attrDiff.Old
if attrDiff.NewComputed {
v = "<computed>"
}
if attrDiff.Sensitive {
u = "<sensitive>"
v = "<sensitive>"
}
attrBuf.WriteString(fmt.Sprintf(
" %s:%s %#v => %#v\n",
attrK,
strings.Repeat(" ", keyLen-len(attrK)),
u,
v))
}
attrString := strings.TrimSpace(attrBuf.String())
if attrString != "" {
attrString = "\n " + attrString
}
var stateIdSuffix string var stateIdSuffix string
if idKey != "" && idValue != "" { if idKey != "" && idValue != "" {
stateIdSuffix = fmt.Sprintf(" [%s=%s]", idKey, idValue) stateIdSuffix = fmt.Sprintf(" [%s=%s]", idKey, idValue)
@ -153,11 +104,10 @@ func (h *UiHook) PreApply(addr addrs.AbsResourceInstance, gen states.Generation,
} }
h.ui.Output(h.Colorize.Color(fmt.Sprintf( h.ui.Output(h.Colorize.Color(fmt.Sprintf(
"[reset][bold]%s: %s%s[reset]%s", "[reset][bold]%s: %s%s[reset]",
dispAddr, dispAddr,
operation, operation,
stateIdSuffix, stateIdSuffix,
attrString,
))) )))
key := addr.String() key := addr.String()