make state output match legacy output

This commit is contained in:
James Bardin 2018-09-06 21:58:14 -04:00 committed by Martin Atkins
parent d50956bdfc
commit 6f429cc81b
1 changed files with 10 additions and 1 deletions

View File

@ -28,8 +28,16 @@ func (s *State) String() string {
return "<nil>"
}
// sort the modules by name for consistent output
modules := make([]string, 0, len(s.Modules))
for m := range s.Modules {
modules = append(modules, m)
}
sort.Strings(modules)
var buf bytes.Buffer
for _, m := range s.Modules {
for _, name := range modules {
m := s.Modules[name]
mStr := m.testString()
// If we're the root module, we just write the output directly.
@ -51,6 +59,7 @@ func (s *State) String() string {
buf.WriteString(step.InstanceKey.String())
buf.WriteByte(']')
}
buf.WriteString(":")
}
buf.WriteByte('\n')