Documentation
¶
Overview ¶
Package diff compares AICR snapshots to detect configuration drift. It performs field-level comparison between two snapshots, reporting added, removed, and modified readings across all measurement types.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteTable ¶
WriteTable writes the diff result as a human-readable table. Returns a structured error wrapping the first write failure encountered (useful for broken-pipe or full-disk scenarios on the target writer).
A nil result is treated as a malformed call rather than a successful empty diff: it returns ErrCodeInvalidRequest so callers don't silently ship a "NO CHANGES" report for what was actually a programming error.
Types ¶
type Change ¶
type Change struct {
// Kind is the type of change (added, removed, modified).
Kind ChangeKind `json:"kind" yaml:"kind"`
// Severity classifies the impact.
Severity Severity `json:"severity" yaml:"severity"`
// Path is the dot-separated location (e.g., "K8s.server.version").
Path string `json:"path" yaml:"path"`
// Baseline is the value in the baseline snapshot. Nil for Added changes.
Baseline *string `json:"baseline,omitempty" yaml:"baseline,omitempty"`
// Target is the value in the target snapshot. Nil for Removed changes.
Target *string `json:"target,omitempty" yaml:"target,omitempty"`
}
Change represents a single field-level difference between two snapshots.
Baseline and Target are pointers so the JSON/YAML schema can distinguish a genuinely-absent side (nil → field omitted via omitempty) from a present reading whose value happens to be the empty string (`&""` → field present as `""`). Conflating these on the wire would make Modified-to-empty indistinguishable from Removed for downstream consumers.
type ChangeKind ¶
type ChangeKind string
ChangeKind describes the type of difference detected.
const ( // Added indicates a value exists in the target but not the baseline. Added ChangeKind = "added" // Removed indicates a value exists in the baseline but not the target. Removed ChangeKind = "removed" // Modified indicates a value changed between baseline and target. Modified ChangeKind = "modified" )
type Result ¶
type Result struct {
// BaselineSource identifies the baseline (file path, ConfigMap URI, etc.).
BaselineSource string `json:"baselineSource,omitempty" yaml:"baselineSource,omitempty"`
// TargetSource identifies the target snapshot.
TargetSource string `json:"targetSource,omitempty" yaml:"targetSource,omitempty"`
// Changes is the list of field-level differences.
Changes []Change `json:"changes" yaml:"changes"`
// Summary contains aggregate counts.
Summary Summary `json:"summary" yaml:"summary"`
}
Result contains the complete diff output.
func Snapshots ¶
func Snapshots(baseline, target *snapshotter.Snapshot) *Result
Snapshots compares two snapshots and returns a structured diff result. The baseline is the reference state; the target is the current state. If either baseline or target is nil, returns an empty Result (no drift).