command: compiles, tests don't pass yet
This commit is contained in:
parent
9ba39d93b7
commit
672bf58337
|
@ -27,15 +27,15 @@ func FormatPlan(p *terraform.Plan, c *colorstring.Colorize) string {
|
|||
|
||||
// We want to output the resources in sorted order to make things
|
||||
// easier to scan through, so get all the resource names and sort them.
|
||||
names := make([]string, 0, len(p.Diff.Resources))
|
||||
for name, _ := range p.Diff.Resources {
|
||||
names := make([]string, 0, len(p.Diff.RootModule().Resources))
|
||||
for name, _ := range p.Diff.RootModule().Resources {
|
||||
names = append(names, name)
|
||||
}
|
||||
sort.Strings(names)
|
||||
|
||||
// Go through each sorted name and start building the output
|
||||
for _, name := range names {
|
||||
rdiff := p.Diff.Resources[name]
|
||||
rdiff := p.Diff.RootModule().Resources[name]
|
||||
|
||||
// Determine the color for the text (green for adding, yellow
|
||||
// for change, red for delete), and symbol, and output the
|
||||
|
|
|
@ -99,7 +99,7 @@ func (m *Meta) Context(copts contextOpts) (*terraform.Context, bool, error) {
|
|||
return nil, false, fmt.Errorf("Error downloading modules: %s", err)
|
||||
}
|
||||
|
||||
opts.Config = mod.Config()
|
||||
opts.Module = mod
|
||||
opts.State = state
|
||||
ctx := terraform.NewContext(opts)
|
||||
return ctx, false, nil
|
||||
|
|
|
@ -80,9 +80,11 @@ func TestPlan_destroy(t *testing.T) {
|
|||
}
|
||||
|
||||
plan := testReadPlan(t, outPath)
|
||||
for _, r := range plan.Diff.Resources {
|
||||
if !r.Destroy {
|
||||
t.Fatalf("bad: %#v", r)
|
||||
for _, m := range plan.Diff.Modules {
|
||||
for _, r := range m.Resources {
|
||||
if !r.Destroy {
|
||||
t.Fatalf("bad: %#v", r)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,6 +54,17 @@ func (d *Diff) RootModule() *ModuleDiff {
|
|||
return root
|
||||
}
|
||||
|
||||
// Empty returns true if the diff has no changes.
|
||||
func (d *Diff) Empty() bool {
|
||||
for _, m := range d.Modules {
|
||||
if !m.Empty() {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (d *Diff) String() string {
|
||||
var buf bytes.Buffer
|
||||
for _, m := range d.Modules {
|
||||
|
|
|
@ -5,6 +5,27 @@ import (
|
|||
"testing"
|
||||
)
|
||||
|
||||
func TestDiffEmpty(t *testing.T) {
|
||||
diff := new(Diff)
|
||||
if !diff.Empty() {
|
||||
t.Fatal("should be empty")
|
||||
}
|
||||
|
||||
mod := diff.AddModule(rootModulePath)
|
||||
mod.Resources["nodeA"] = &InstanceDiff{
|
||||
Attributes: map[string]*ResourceAttrDiff{
|
||||
"foo": &ResourceAttrDiff{
|
||||
Old: "foo",
|
||||
New: "bar",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
if diff.Empty() {
|
||||
t.Fatal("should not be empty")
|
||||
}
|
||||
}
|
||||
|
||||
func TestModuleDiff_Empty(t *testing.T) {
|
||||
diff := new(ModuleDiff)
|
||||
if !diff.Empty() {
|
||||
|
|
Loading…
Reference in New Issue