1
0
Fork 0
mirror of https://github.com/kyverno/policy-reporter.git synced 2024-12-14 11:57:32 +00:00

map scope to result resources

Signed-off-by: Frank Jogeleit <frank.jogeleit@web.de>
This commit is contained in:
Frank Jogeleit 2023-11-17 09:28:33 +01:00
parent 1c68da3797
commit 603f70a53e

View file

@ -96,7 +96,7 @@ func (q *Queue) processNextItem() bool {
defer q.lock.Unlock()
q.cache.Delete(key)
}()
q.debouncer.Add(report.LifecycleEvent{Type: report.Deleted, PolicyReport: polr})
q.debouncer.Add(report.LifecycleEvent{Type: report.Deleted, PolicyReport: mapResource(polr)})
return true
}
@ -120,6 +120,19 @@ func (q *Queue) processNextItem() bool {
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() {
scope := polr.GetScope()
if len(r.Resources) == 0 && scope != nil {
r.Resources = append(r.Resources, *scope)
}
}
return polr
}
func (q *Queue) handleErr(err error, key interface{}) {
if err == nil {
q.queue.Forget(key)