MCPcopy
hub / github.com/aquasecurity/trivy / Write

Method Write

pkg/k8s/report/table.go:54–82  ·  view source on GitHub ↗
(ctx context.Context, report Report)

Source from the content-addressed store, hash-verified

52}
53
54func (tw TableWriter) Write(ctx context.Context, report Report) error {
55 switch tw.Report {
56 case AllReport:
57 t := pkgReport.NewWriter(pkgReport.Options{
58 Output: tw.Output,
59 Severities: tw.Severities,
60 // k8s has its own summary report, so we only need to show the detailed tables here
61 TableModes: []types.TableMode{
62 types.Detailed,
63 },
64 })
65 for i, r := range report.Resources {
66 if r.Report.Results.Failed() {
67 updateTargetContext(&report.Resources[i])
68 err := t.Write(ctx, r.Report)
69 if err != nil {
70 return err
71 }
72 }
73 }
74 case SummaryReport:
75 writer := NewSummaryWriter(tw.Output, tw.Severities, tw.ColumnHeading)
76 return writer.Write(report)
77 default:
78 return xerrors.Errorf(`report %q not supported. Use "summary" or "all"`, tw.Report)
79 }
80
81 return nil
82}
83
84// updateTargetContext add context namespace, kind and name to the target
85func updateTargetContext(r *Resource) {

Callers 1

WriteFunction · 0.95

Calls 5

WriteMethod · 0.95
WriteMethod · 0.95
updateTargetContextFunction · 0.85
NewSummaryWriterFunction · 0.70
FailedMethod · 0.45

Tested by

no test coverage detected