Documentation
¶
Overview ¶
Package diff compares two sets of rendered Kubernetes manifests and reports the resources whose rendered form differs.
RenderDocs is the entry point, and it takes one of two paths by Format. The dyff text styles (human default, github, brief, gitlab, gitea) render the whole set through dyff at once: dyff pairs documents by their Kubernetes identity and labels each diff natively with apiVersion/kind/namespace/name. The plain unified diff takes a per-resource path — each resource is paired against its counterpart, keyed by parent KS/HR and resource identity (not just name, so a Deployment from HelmRelease A never diffs against the same-named Deployment from HelmRelease B), and the per-resource bodies are concatenated.
Most styles delegate to dyff, whose K8s-aware comparison pairs named list entries (containers, env vars) by their identifier, so reordering a list yields an `⇆ order changed` marker instead of a wall of phantom value-line churn:
- human (default) — dyff's colored, human-readable report.
- github — dyff path-keyed diff syntax (`@@ <path> @@`, `+`/`-`, `!`); GitHub's diff lexer renders it natively.
- brief — dyff's one-line-per-change summary.
- gitlab / gitea — dyff diff syntax with forge-specific prefixes.
- diff — a plain unified diff (`diff -u`) of each resource's YAML; not K8s-aware, but consumable by any unified-diff tooling.
Options.StripAttrs is applied to a deep-copied tree before the comparison runs — used to drop chart-bump noise (`helm.sh/chart`, `checksum/config`, …) that rotates on every Helm upgrade but carries no review-relevant signal. ConfigMap binaryData is summarized to a content hash for the same reason.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RenderDocs ¶
RenderDocs is the top-level entry point: it compares the two doc sets and returns the formatted diff for opts.Format. The dyff text styles (github/human/brief/gitlab/gitea, and the zero value) render the whole set through dyff for native per-resource labels; FormatDiff takes the per-resource unified-diff path.
Types ¶
type Format ¶
type Format string
Format selects the diff output flavor. The github/human/brief/gitlab/ gitea styles map to dyff's own output styles; diff is a plain unified diff.
const ( // FormatGitHub is dyff's `--output github` mode: path-based diff // syntax (`@@`, `+`, `-`, `!`) that GitHub's diff lexer renders // natively as a colored diff block when wrapped in a “`diff // fence. K8s-aware: list entries are matched by identifier // (container name, env-var name, etc.), so reordering a list // produces no diff churn. FormatGitHub Format = "github" // FormatDiff is a standard unified diff (`diff -u` / `git diff` // style) of each resource's YAML. Not Kubernetes-aware — it diffs // lines, so a reordered list shows churn — but familiar and // consumable by any unified-diff tooling. FormatDiff Format = "diff" // FormatHuman is dyff's colored, human-readable report — the default // style, and the zero value. FormatHuman Format = "human" // FormatBrief is dyff's one-line-per-change summary. FormatBrief Format = "brief" // FormatGitLab is dyff's GitLab diff syntax (`=` path/root prefixes). FormatGitLab Format = "gitlab" // FormatGitea is dyff's Gitea/Forgejo diff syntax. FormatGitea Format = "gitea" // FormatHTML renders a self-contained HTML document: a per-resource, // GitHub-style diff with YAML syntax highlighting (via chroma) and a // side-by-side ⇄ unified toggle. Built on the same line diff as // FormatDiff (not Kubernetes-aware). Meant for browser review or a CI // artifact, not the terminal. FormatHTML Format = "html" )
Recognized Format values.
type Options ¶
type Options struct {
// StripAttrs lists annotation/label keys removed from each
// manifest's metadata (and pod-template metadata) before the diff
// is computed. Cuts chart-bump noise — annotations like
// `helm.sh/chart` or `checksum/config` whose values rotate on
// every chart bump would otherwise produce a diff entry per
// resource. dyff matches K8s lists by identifier but still
// reports string-value changes verbatim, so this pre-filter still
// earns its keep.
StripAttrs []string
// StripFields lists dotted spec field-paths (e.g.
// "spec.restic.unlock") deleted from each manifest before the diff
// is computed. Same rationale as StripAttrs but for volatile values
// charts template into the spec rather than metadata — notably
// volsync's `unlock: {{ now }}`, which rotates every render and
// cannot be stabilized at render time (Helm exposes no funcMap
// hook). See manifest.StripResourceFields.
StripFields []string
// Format selects the output style (see the Format constants). The
// zero value renders the human default.
Format Format
}
Options tunes RenderDocs behavior.
type Parent ¶
type Parent struct {
Kind string
Namespace string
Name string
// Path is the Flux Kustomization spec.path (only set for KS
// parents). Slash-normalized, with the conventional `./` prefix
// stripped. Disambiguates two KS parents that share a (kind, ns,
// name) but render from different overlays.
Path string
}
Parent identifies the Flux Kustomization or HelmRelease that rendered a manifest. It never appears in the output — it's a pairing discriminator (see pairKey) so a Deployment rendered by HelmRelease A never diffs against the same-named Deployment from HelmRelease B.