Skip to content

Commit

Permalink
test ordering
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Milchev <ivan@mondoo.com>
  • Loading branch information
imilchev committed Jul 27, 2023
1 parent eafd2f5 commit 18897ab
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions policy/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,12 +444,14 @@ func (p *Policy) updateAllChecksums(ctx context.Context,
}

// CHECKS (must be sorted)
sort.Slice(group.Checks, func(i, j int) bool {
return group.Checks[i].Mrn < group.Checks[j].Mrn
checks := make([]*explorer.Mquery, len(group.Checks))
copy(checks, group.Checks)
sort.Slice(checks, func(i, j int) bool {
return checks[i].Mrn < checks[j].Mrn
})

for i := range group.Checks {
check := group.Checks[i]
for i := range checks {
check := checks[i]

if base, ok := bundle.Queries[check.Mrn]; ok {
check = check.Merge(base)
Expand Down Expand Up @@ -482,12 +484,14 @@ func (p *Policy) updateAllChecksums(ctx context.Context,
}

// DATA (must be sorted)
sort.Slice(group.Queries, func(i, j int) bool {
return group.Queries[i].Mrn < group.Queries[j].Mrn
queries := make([]*explorer.Mquery, len(group.Queries))
copy(queries, group.Queries)
sort.Slice(queries, func(i, j int) bool {
return queries[i].Mrn < queries[j].Mrn
})

for i := range group.Queries {
query := group.Queries[i]
for i := range queries {
query := queries[i]

if base, ok := bundle.Queries[query.Mrn]; ok {
query = query.Merge(base)
Expand Down

0 comments on commit 18897ab

Please sign in to comment.