(ctx context.Context, report Report)
| 52 | } |
| 53 | |
| 54 | func (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 |
| 85 | func updateTargetContext(r *Resource) { |
no test coverage detected