diff

package
v0.0.0-...-51868e1 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Lint

func Lint(changes []Change, images []api.ImageChange, parents map[string]ParentInfo) []api.Warning

Lint runs the diff-lint rules over the changed resources (and the diff's image changes) and returns the warnings in rule order. parents carries the Flux-semantic facts about each producing Kustomization/HelmRelease (suspend/prune — see ParentInfo); nil is fine and simply mutes the parent-aware rules. Every rule is api.LevelCaution today (advisory → a neutral check); the summary groups warnings by tier (see api.WarningsByLevel).

func Render

func Render(in RenderInput) (api.DiffResult, error)

Render turns the paired changes into the full api.DiffResult: per-resource unified + side-by-side rows with YAML syntax highlighting, the navigation tree, and the review signals (impact, images, failures, danger-lint).

func Summarize

func Summarize(changes []Change) api.Impact

Summarize computes the blast-radius banner (api.Impact) over the changed resources: total count, distinct producing parents, the sorted set of affected namespaces, and how many CustomResourceDefinitions changed.

Types

type Change

type Change struct {
	Status    string // api status: "added" | "changed" | "removed"
	Kind      string
	Namespace string
	Name      string
	Parent    string // producing HelmRelease/Kustomization label (for Impact)
	Old       map[string]any
	New       map[string]any
	// OldChart / NewChart are the resource's "helm.sh/chart" label
	// ("<name>-<version>") before and after, captured before normalize strips it
	// — used to flag a major chart-version bump. Empty for non-Helm resources or
	// the absent side of an add/remove.
	OldChart string
	NewChart string
}

Change is the minimal view of one changed resource the danger-lint needs: its status and identity plus the pre-image (Old) and post-image (New) manifests. Old is nil for added resources; New is nil for removed ones.

type ParentInfo

type ParentInfo struct {
	Found           bool
	IsKustomization bool
	Suspended       bool // spec.suspend (absent = false)
	Prune           bool // spec.prune, Kustomizations only (absent = false)
}

ParentInfo carries the Flux-semantic bits of one producing Kustomization / HelmRelease, keyed in Lint's parents map by the same "Kind ns/name" label Change.Parent uses. The engine looks the doc up in the rendered manifest sets — head side first (the post-merge truth), base side when the PR removes the parent itself. Found=false (the zero value) means the parent doc wasn't located; every rule below then stays quiet rather than guessing.

type RenderInput

type RenderInput struct {
	PRNumber int
	HeadSHA  string
	Changes  []Change
	Images   []api.ImageChange
	Failures []api.RenderFailure
	// MaxResources caps how many changes are fully rendered into per-resource
	// rows (the dominant memory/payload cost). Excess changes are dropped from
	// the rendered set and counted in DiffResult.Truncated; the summary and
	// impact still reflect the full change set. <=0 means no cap.
	MaxResources int
	// Parents carries the Flux-semantic facts (suspend/prune) about each
	// producing Kustomization/HelmRelease, keyed by the Change.Parent label —
	// see ParentInfo. Optional; nil mutes the parent-aware lint rules.
	Parents map[string]ParentInfo
}

RenderInput is everything the renderer needs to produce a DiffResult. The engine builds it from the two flate renders (merge-base and head): the paired changes, the image diff, and any render failures.

Jump to

Keyboard shortcuts

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