sort constraints for consistent output

This commit is contained in:
James Bardin 2017-06-09 09:15:38 -04:00 committed by Martin Atkins
parent 190d5fae76
commit ea3d9c86ba
1 changed files with 7 additions and 0 deletions

View File

@ -1,6 +1,8 @@
package discovery
import (
"sort"
version "github.com/hashicorp/go-version"
)
@ -61,6 +63,11 @@ func (s Constraints) Append(other Constraints) Constraints {
raw = append(raw, s.raw...)
raw = append(raw, other.raw...)
// while the set is unordered, we sort these lexically for consistent output
sort.Slice(raw, func(i, j int) bool {
return raw[i].String() < raw[j].String()
})
return Constraints{raw}
}