Documentation
¶
Overview ¶
Package diff compares objects across clusters or across two bundles from the same customer (before and after), with metadata noise removed and absence judged against coverage rather than assumed.
Index ¶
- Constants
- Variables
- func Clean(obj map[string]any) map[string]any
- func IsDeclared(ws *store.Workspace) bool
- func Unified(a, b, fromName, toName string, ctx int) string
- func YAML(obj map[string]any) string
- type Change
- type DriftObject
- type DriftReport
- type DriftScope
- type FieldDiff
- type Report
- type Side
- type VersionChange
Constants ¶
const ( DeclaredLabel = "Declared (repo)" LiveLabel = "Live (cluster)" )
Labels for the two sides when a repo scan is compared with a capture.
Variables ¶
var DefaultedFields = []string{}/* 120 elements not displayed */
DefaultedFields are filled in by the API server or a controller when the manifest leaves them out. A path is ignored when the declared object does not set it, and compared as usual when it does. "[]" matches every list element. Extend this list when a new default shows up as noise.
Functions ¶
func Clean ¶
Clean returns a copy of obj without fields that differ between captures of an unchanged object: uid, resourceVersion, timestamps, managedFields, last-applied annotations and condition transition times.
func IsDeclared ¶
IsDeclared reports whether ws is a repo scan.
Types ¶
type Change ¶
type Change struct {
Cluster string `json:"cluster"`
Group string `json:"group"`
Resource string `json:"resource"`
Kind string `json:"kind"`
Namespace string `json:"namespace"`
Name string `json:"name"`
Change string `json:"change"` // added, removed, changed
Fields []string `json:"fields,omitempty"`
Before string `json:"before,omitempty"`
After string `json:"after,omitempty"`
}
Change is one object that differs between two bundles.
type DriftObject ¶
type DriftObject struct {
Group string `json:"group"`
Kind string `json:"kind"`
Namespace string `json:"namespace,omitempty"`
Name string `json:"name"`
Source string `json:"source,omitempty"` // the file that declares it
Fields []FieldDiff `json:"fields,omitempty"`
}
DriftObject is one object in a drift report.
type DriftReport ¶
type DriftReport struct {
Declared Side `json:"declared"`
Live Side `json:"live"`
Labels [2]string `json:"labels"`
InGitOnly []DriftObject `json:"inGitNotInCluster"`
InClusterOnly []DriftObject `json:"inClusterNotInGit"`
Differs []DriftObject `json:"differs"`
Same int `json:"same"`
Scope DriftScope `json:"scope"`
NotComparable []string `json:"notComparable"`
Summary map[string]int `json:"summary"`
}
DriftReport compares declared state (a repo scan) with live state (a capture of the cluster).
func Drift ¶
func Drift(declared, live *store.Workspace) DriftReport
Drift compares a repo scan with a capture of the cluster, ignoring cluster names: what Git declares that the cluster lacks, what the cluster runs in the repository's namespaces and kinds that Git does not declare (applied by hand), and fields that differ once status, metadata noise and defaulted fields are removed.
func (DriftReport) Text ¶
func (r DriftReport) Text() string
Text renders the drift report for the terminal.
type DriftScope ¶
DriftScope is where "in the cluster, not in Git" was looked for: the namespaces and kinds the repository declares.
type FieldDiff ¶
type FieldDiff struct {
Path string `json:"path"`
Declared string `json:"declared"`
Live string `json:"live"`
}
FieldDiff is one differing field.
type Report ¶
type Report struct {
Before Side `json:"before"`
After Side `json:"after"`
Changes []Change `json:"changes"`
Versions []VersionChange `json:"versions"`
NewFindings []analyze.Finding `json:"newFindings"`
Resolved []analyze.Finding `json:"resolvedFindings"`
NotComparable []string `json:"notComparable"`
Summary map[string]int `json:"summary"`
Drift *DriftReport `json:"drift,omitempty"` // set when one side is a repo scan
}
Report is the bundle-to-bundle comparison.
type Side ¶
type Side struct {
BundleID string `json:"bundleId"`
Case string `json:"case"`
Captured time.Time `json:"captured"`
Clusters []string `json:"clusters"`
Verified bool `json:"verified"`
Source string `json:"source,omitempty"` // "repo" for a repo scan
Repo string `json:"repo,omitempty"` // name@commit of a repo scan
Label string `json:"label,omitempty"` // Declared (repo) or Live (cluster) when one side is a repo scan
}
Side describes one bundle.
type VersionChange ¶
type VersionChange struct {
Cluster string `json:"cluster"`
Namespace string `json:"namespace"`
Workload string `json:"workload"`
Container string `json:"container"`
Before string `json:"before"`
After string `json:"after"`
}
VersionChange is a component image that moved between bundles.