Skip to content

Commit

Permalink
fix: add context to Target finding on k8s table view
Browse files Browse the repository at this point in the history
Signed-off-by: chenk <[email protected]>
  • Loading branch information
chen-keinan committed Feb 21, 2024
1 parent 327cf88 commit 5140cb3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/k8s/report/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
}
}

0 comments on commit 5140cb3

Please sign in to comment.