diff

package
v0.4.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const (
	DeclaredLabel = "Declared (repo)"
	LiveLabel     = "Live (cluster)"
)

Labels for the two sides when a repo scan is compared with a capture.

Variables

View Source
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

func Clean(obj map[string]any) map[string]any

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

func IsDeclared(ws *store.Workspace) bool

IsDeclared reports whether ws is a repo scan.

func YAML

func YAML(obj map[string]any) string

YAML renders a cleaned object.

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.

func (DriftObject) ID

func (o DriftObject) ID() string

ID is Kind ns/name.

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) JSON

func (r DriftReport) JSON() []byte

JSON renders the drift report.

func (DriftReport) Text

func (r DriftReport) Text() string

Text renders the drift report for the terminal.

type DriftScope

type DriftScope struct {
	Namespaces []string `json:"namespaces"`
	Kinds      []string `json:"kinds"`
}

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.

func Compare

func Compare(before, after *store.Workspace) Report

Compare reports what changed from before to after. When one side is a repo scan it reports drift instead (see Drift), with the declared side as "before": in Git and not in the cluster reads as removed, in the cluster and not in Git as added.

func (Report) JSON

func (r Report) JSON() []byte

JSON renders the report.

func (Report) Text

func (r Report) Text(showYAML bool) string

Text renders the report for the terminal.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL