command/format: show planned changes in rendered plan

This codepath is going to be significantly changed before release to make
it support structural diff of the new data types, but this lets us lean on
the old renderer to produce partial output in the mean time while we
continue to work on getting things working end-to-end after the
considerable refactoring that's been going on.
This commit is contained in:
Martin Atkins 2018-08-27 15:20:41 -07:00
parent bd299b9a22
commit 5731703de5
1 changed files with 5 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package format
import (
"bytes"
"fmt"
"log"
"sort"
"strings"
@ -63,6 +64,7 @@ type PlanStats struct {
// NewPlan produces a display-oriented Plan from a terraform.Plan.
func NewPlan(changes *plans.Changes) *Plan {
log.Printf("[TRACE] NewPlan for %#v", changes)
ret := &Plan{}
if changes == nil {
// Nothing to do!
@ -71,6 +73,7 @@ func NewPlan(changes *plans.Changes) *Plan {
for _, rc := range changes.Resources {
addr := rc.Addr
log.Printf("[TRACE] NewPlan found %s", addr)
dataSource := addr.Resource.Resource.Mode == addrs.DataResourceMode
// We create "delete" actions for data resources so we can clean
@ -119,6 +122,8 @@ func NewPlan(changes *plans.Changes) *Plan {
// don't include any attributes here.
// FIXME: Implement the structural diff renderer to replace this
// codepath altogether.
ret.Resources = append(ret.Resources, did)
}
// Sort the instance diffs by their addresses for display.