Skip to content

Commit

Permalink
fix resource mapping reference issue
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Jogeleit <[email protected]>
  • Loading branch information
fjogeleit committed Nov 27, 2023
1 parent 4d18403 commit a039531
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# Changelog

# Next
* Policy Reporter v2.17.4
* Fix Result Resource mapping
* Policy Reporter v2.17.3
* Fix handling if metric cache fallback

# 2.21.2
* Policy Reporter v2.17.2
* Fix ID generation for Policy Reports which using `scope` as resource reference
* Fix ID generation for PolicyReportResults which using `scope` as resource reference
* Add optional `message` metric label
* Helm Chart
* fix: Add chart parameters for setting `revisionHistoryLimit` [[#363](https://github.com/kyverno/policy-reporter/pull/363) by [bodgit](https://github.com/bodgit)]
Expand Down
7 changes: 5 additions & 2 deletions pkg/kubernetes/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,19 +115,22 @@ func (q *Queue) processNextItem() bool {

q.handleErr(err, key)

q.debouncer.Add(report.LifecycleEvent{Type: event, PolicyReport: polr})
q.debouncer.Add(report.LifecycleEvent{Type: event, PolicyReport: mapResource(polr)})

return true
}

// each result needs to know its resource it belongs to, to generate internal unique IDs
func mapResource(polr pr.ReportInterface) pr.ReportInterface {
for _, r := range polr.GetResults() {
results := polr.GetResults()
for i, r := range results {
scope := polr.GetScope()

if len(r.Resources) == 0 && scope != nil {
r.Resources = append(r.Resources, *scope)
}

results[i] = r
}

return polr
Expand Down

0 comments on commit a039531

Please sign in to comment.