Marshal plan#relevant_attributes in deterministic order (#327)

Signed-off-by: Marcin Wyszynski <marcin.pixie@gmail.com>
This commit is contained in:
Marcin Wyszynski
2023-09-07 13:36:16 +02:00
committed by GitHub
parent c22a387167
commit 992b5d604a
2 changed files with 13 additions and 6 deletions

View File

@@ -682,6 +682,13 @@ func (p *Plan) marshalRelevantAttrs(plan *plans.Plan) error {
p.RelevantAttributes = append(p.RelevantAttributes, ResourceAttr{addr, path})
}
// We sort the relevant attributes by resource address to make the output
// deterministic. Our own equivalence tests rely on it.
sort.Slice(p.RelevantAttributes, func(i, j int) bool {
return p.RelevantAttributes[i].Resource < p.RelevantAttributes[j].Resource
})
return nil
}