terraform: alphabetize attributes in diff

This commit is contained in:
Mitchell Hashimoto 2014-06-10 11:27:17 -07:00
parent 32afc6dc70
commit 36a99b5920
3 changed files with 13 additions and 4 deletions

View File

@ -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>"

View File

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

View File

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