Documentation
¶
Overview ¶
Package compare produces a structured diff between two Fleetsweeper reports: what changed in the Fleet Score, which findings are new, which resolved, which persisted, and how cluster statuses moved.
The diff is the unit of operator review: "what changed since the deploy" or "what got fixed in the last hour". Each renderer (text, json, markdown) wraps the same ScanDiff so reports can be embedded in tickets, chat, or CI pipelines without re-deriving anything.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RenderMarkdown ¶
RenderMarkdown returns a Markdown rendering of the diff suitable for pasting into a PR description or ticket.
func RenderText ¶
RenderText returns a plain-text rendering of the diff suitable for the terminal. When color is true severities and deltas get ANSI codes.
Types ¶
type ClusterStatusChange ¶
type ClusterStatusChange struct {
// Cluster is the kubeconfig context name.
Cluster string `json:"cluster"`
// Before is the status in A.
Before string `json:"before"`
// After is the status in B.
After string `json:"after"`
}
ClusterStatusChange captures one cluster's health-status transition.
type ScanDiff ¶
type ScanDiff struct {
// ScoreBefore is the Fleet Score from A.
ScoreBefore int `json:"score_before"`
// ScoreAfter is the Fleet Score from B.
ScoreAfter int `json:"score_after"`
// GradeBefore is the grade from A.
GradeBefore string `json:"grade_before"`
// GradeAfter is the grade from B.
GradeAfter string `json:"grade_after"`
// New are findings present in B but not in A.
New []report.Finding `json:"new"`
// Resolved are findings present in A but not in B.
Resolved []report.Finding `json:"resolved"`
// Persisted are findings present in both reports.
Persisted []report.Finding `json:"persisted"`
// ClusterStatusChanges lists clusters whose health status moved.
ClusterStatusChanges []ClusterStatusChange `json:"cluster_status_changes"`
// AddedClusters are clusters present in B but not in A.
AddedClusters []string `json:"added_clusters"`
// RemovedClusters are clusters present in A but not in B.
RemovedClusters []string `json:"removed_clusters"`
// CriticalBefore is the count of critical findings in A.
CriticalBefore int `json:"critical_before"`
// CriticalAfter is the count of critical findings in B.
CriticalAfter int `json:"critical_after"`
// WarningBefore is the count of warning findings in A.
WarningBefore int `json:"warning_before"`
// WarningAfter is the count of warning findings in B.
WarningAfter int `json:"warning_after"`
}
ScanDiff captures every meaningful change between two reports. The "old" (A) report is the reference; the "new" (B) report is what we compare it to. All fields are populated even when empty so renderers can show "0 new findings" rather than failing on a nil deref.