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 DriftLines ¶ added in v0.10.0
DriftLines renders up to limit ledger rows as one line each: the cluster, how its deviation mass moved, the field that moved most, and the outlier flags it gained or lost with the scan of each flip when known. A final line counts the rows left out.
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"`
// SetDrift lists persisted set-membership findings whose missing members
// changed, so a cluster that loses another CRD shows up even though its
// finding persisted.
SetDrift []SetDrift `json:"set_drift"`
// Drift is the drift ledger from A to B: which clusters moved against
// the fleet norm, by how much, and on which fields.
Drift report.Ledger `json:"drift"`
// 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.
type SetDrift ¶ added in v0.10.0
type SetDrift struct {
// Cluster is the kubeconfig context name.
Cluster string `json:"cluster"`
// Scanner is the scanner that reported the set.
Scanner string `json:"scanner"`
// Field is the set field, e.g. crd_names.
Field string `json:"field"`
// NewlyMissing are consensus members missing in B that were not missing in A.
NewlyMissing []string `json:"newly_missing"`
// Restored are members missing in A that are no longer missing in B.
Restored []string `json:"restored"`
}
SetDrift is a change in the consensus members one cluster lacks for one set field between two reports.