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 4ea37d6
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions policy/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,12 +444,13 @@ 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 := 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 +483,13 @@ 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 := 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 4ea37d6

Please sign in to comment.