From 5140cb358275fed60fb76a324abea9c915a7ed42 Mon Sep 17 00:00:00 2001 From: chenk Date: Sun, 11 Feb 2024 11:19:16 +0200 Subject: [PATCH] fix: add context to Target finding on k8s table view Signed-off-by: chenk --- pkg/k8s/report/table.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/k8s/report/table.go b/pkg/k8s/report/table.go index 524a1c389b03..3141af3c6c49 100644 --- a/pkg/k8s/report/table.go +++ b/pkg/k8s/report/table.go @@ -50,8 +50,9 @@ func (tw TableWriter) Write(ctx context.Context, report Report) error { Output: tw.Output, Severities: tw.Severities, } - for _, r := range report.Resources { + for i, r := range report.Resources { if r.Report.Results.Failed() { + updateTargetContext(&report.Resources[i]) err := t.Write(ctx, r.Report) if err != nil { return err @@ -67,3 +68,10 @@ func (tw TableWriter) Write(ctx context.Context, report Report) error { return nil } + +// updateTargetContext add context namespace, kind and name to the target +func updateTargetContext(r *Resource) { + for i := range r.Report.Results { + r.Report.Results[i].Target = r.fullname() + } +}