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 12, 2024
1 parent ffe797a commit 91fc9c9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/k8s/report/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package report

import (
"context"
"fmt"
"io"
"strings"
"sync"

"golang.org/x/xerrors"
Expand Down Expand Up @@ -73,7 +75,11 @@ func (tw TableWriter) Write(ctx context.Context, report Report) error {

// updateTargetContext add context namespace, kind and name to the target
func updateTargetContext(r *Resource) {
targetName := fmt.Sprintf("namespace: %s, %s: %s", r.Namespace, strings.ToLower(r.Kind), r.Name)
if r.Kind == "NodeComponents" {
targetName = fmt.Sprintf("node: %s", r.Name)
}
for i := range r.Report.Results {
r.Report.Results[i].Target = r.fullname()
r.Report.Results[i].Target = targetName
}
}

0 comments on commit 91fc9c9

Please sign in to comment.