terraform: alphabetize attributes in diff

pull/5/head
Mitchell Hashimoto 12 years ago
parent 32afc6dc70
commit 36a99b5920

@ -33,10 +33,19 @@ func (d *Diff) String() string {
sort.Strings(names)
for _, name := range names {
rdiff := d.Resources[name]
buf.WriteString(name + "\n")
rdiff := d.Resources[name]
for attrK, attrDiff := range rdiff.Attributes {
keys := make([]string, 0, len(rdiff.Attributes))
for key, _ := range rdiff.Attributes {
keys = append(keys, key)
}
sort.Strings(keys)
for _, attrK := range keys {
attrDiff := rdiff.Attributes[attrK]
v := attrDiff.New
if attrDiff.NewComputed {
v = "<computed>"

@ -32,6 +32,6 @@ func TestDiff_String(t *testing.T) {
const diffStrBasic = `
nodeA
foo: "foo" => "bar"
bar: "foo" => "<computed>"
foo: "foo" => "bar"
`

@ -401,6 +401,6 @@ const testTerraformDiffComputedStr = `
aws_instance.bar
foo: "" => "<computed>"
aws_instance.foo
num: "" => "2"
id: "" => "<computed>"
num: "" => "2"
`

Loading…
Cancel
Save