renderAuditDiffJSON outputs audit diffs as JSON to stdout. When a single diff is provided, outputs a JSON object for backward compatibility. When multiple diffs are provided, outputs a JSON array.
(diffs []*AuditDiff)
| 18 | // When a single diff is provided, outputs a JSON object for backward compatibility. |
| 19 | // When multiple diffs are provided, outputs a JSON array. |
| 20 | func renderAuditDiffJSON(diffs []*AuditDiff) error { |
| 21 | auditDiffRenderLog.Printf("Rendering %d audit diff(s) as JSON", len(diffs)) |
| 22 | if len(diffs) == 0 { |
| 23 | return errors.New("no diffs to render") |
| 24 | } |
| 25 | encoder := json.NewEncoder(os.Stdout) |
| 26 | encoder.SetIndent("", " ") |
| 27 | if len(diffs) == 1 { |
| 28 | return encoder.Encode(diffs[0]) |
| 29 | } |
| 30 | return encoder.Encode(diffs) |
| 31 | } |
| 32 | |
| 33 | // renderAuditDiffMarkdown outputs audit diffs as markdown to stdout. |
| 34 | // Multiple diffs are separated by a horizontal rule. |