refactor: sort difference's changelogs

main
sundowndev 2021-03-29 11:21:45 +02:00
parent fa9132f14c
commit a637de6f8c
1 changed files with 13 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package analyser
import (
"encoding/json"
"sort"
"strings"
"github.com/r3labs/diff/v2"
@ -205,5 +206,17 @@ func SortDifferences(diffs []Difference) []Difference {
}
return diffs[i].Res.TerraformId() < diffs[j].Res.TerraformId()
})
for _, d := range diffs {
SortChanges(d.Changelog)
}
return diffs
}
func SortChanges(changes []Change) []Change {
sort.SliceStable(changes, func(i, j int) bool {
return strings.Join(changes[i].Path, ".") < strings.Join(changes[j].Path, ".")
})
return changes
}