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 11, 2024
1 parent 535b5a9 commit ffe797a
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 @@ -52,8 +52,9 @@ func (tw TableWriter) Write(ctx context.Context, report Report) error {
Severities: tw.Severities,
ShowMessageOnce: &sync.Once{},
}
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 @@ -69,3 +70,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 ffe797a

Please sign in to comment.