diff

package
v0.2.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: GPL-3.0 Imports: 19 Imported by: 1 module, 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildBreakdown

func BuildBreakdown(result *DiffResult, keyFn func(ResourceChange) string) map[string]ChangeBreakdown

BuildBreakdown groups changes by the given key function and returns breakdown counts.

func ClusterBreakdown

func ClusterBreakdown(result *DiffResult) map[string]ChangeBreakdown

ClusterBreakdown returns change counts grouped by cluster name.

func Diff

func Diff(a, b *render.Render, w io.Writer) error

Diff computes a unified diff between two Renders and writes the result to w.

func GenerateFilterConfig

func GenerateFilterConfig(diffs []FieldDiff) ([]byte, error)

func KindBreakdown

func KindBreakdown(result *DiffResult) map[string]ChangeBreakdown

KindBreakdown returns change counts grouped by resource Kind.

func UnifiedDiff

func UnifiedDiff(name, before, after string) string

UnifiedDiff computes a unified diff between before and after strings.

func WritePermadiffConfig

func WritePermadiffConfig(a, b *render.Render, out io.Writer) error

Types

type ChangeBreakdown

type ChangeBreakdown struct {
	Added    int `json:"added"`
	Modified int `json:"modified"`
	Deleted  int `json:"deleted"`
	Total    int `json:"total"`
}

ChangeBreakdown holds added/modified/deleted counts for a category like kind.

type DiffChangeJSON

type DiffChangeJSON struct {
	LogicalID    string             `json:"logicalId,omitempty"`
	Action       string             `json:"action"`
	Provenance   render.Provenance  `json:"provenance"`
	BeforeOrigin *render.Provenance `json:"beforeOrigin,omitempty"`
	AfterOrigin  *render.Provenance `json:"afterOrigin,omitempty"`
	ObjectRef    ObjectRef          `json:"objectRef"`
	Cluster      string             `json:"cluster,omitempty"`
	Producer     string             `json:"producer,omitempty"`
	Old          map[string]any     `json:"old"`
	New          map[string]any     `json:"new"`
	UnifiedDiff  string             `json:"unifiedDiff"`
}

DiffChangeJSON represents a modified resource with before/after snapshots.

type DiffResult

type DiffResult struct {
	Clustered bool
	Clusters  []string
	Added     []ResourceChange
	Deleted   []ResourceChange
	Modified  []ResourceChange
}

DiffResult holds the structured result of a diff between two renders.

func ChangeSet

func ChangeSet(a, b *render.Render) (*DiffResult, error)

ChangeSet computes structured resource changes between two renders.

func DiffWithResult

func DiffWithResult(a, b *render.Render, w io.Writer) (*DiffResult, error)

DiffWithResult computes a unified diff and returns structured change metadata. The unified diff text is written to w.

func DiffWithResultClustered

func DiffWithResultClustered(left, right map[string]*render.Render, w io.Writer) (*DiffResult, error)

DiffWithResultClustered diffs two sets of renders keyed by cluster name. Clusters present on both sides are diffed normally. Clusters only on the left side produce all-deleted results; clusters only on the right produce all-added results.

func LogicalChangeSet

func LogicalChangeSet(before, after []plugin.Resource) (*DiffResult, error)

LogicalChangeSet compares unnamed outputs by their stable logical IDs. Object comparison ignores YAML formatting, while diffs retain the original YAML.

func (*DiffResult) ByKind

func (r *DiffResult) ByKind() map[string]int

ByKind returns counts grouped by resource Kind.

func (*DiffResult) Changes

func (r *DiffResult) Changes() []ResourceChange

Changes returns all resource changes in added, modified, deleted order.

func (*DiffResult) Sort

func (r *DiffResult) Sort()

Sort applies deterministic ordering to all change groups.

func (*DiffResult) Summary

func (r *DiffResult) Summary() ResultSummary

Summary returns common diff projections for reports and command output.

func (*DiffResult) ToJSON

func (r *DiffResult) ToJSON() *DiffResultJSON

ToJSON converts the diff result to a JSON-serializable structure.

func (*DiffResult) TotalChanged

func (r *DiffResult) TotalChanged() int

TotalChanged returns the total number of changed resources.

func (*DiffResult) WriteUnified

func (r *DiffResult) WriteUnified(w io.Writer)

WriteUnified writes the unified text representation of a change set.

type DiffResultJSON

type DiffResultJSON struct {
	Changes  []DiffChangeJSON `json:"changes"`
	Added    []map[string]any `json:"added"`
	Deleted  []ObjectRef      `json:"deleted"`
	Modified []DiffChangeJSON `json:"modified"`
}

DiffResultJSON is the JSON representation of a manifest diff.

type FieldDiff

type FieldDiff struct {
	LogicalID string
	GVK       resid.Gvk
	Name      string
	Namespace string
	FieldPath []string
	IsLeaf    bool
}

func DetectLogicalPermadiffs

func DetectLogicalPermadiffs(before, after []plugin.Resource) ([]FieldDiff, error)

DetectLogicalPermadiffs discovers unstable fields in matched logical outputs.

func DetectPermadiffs

func DetectPermadiffs(a, b *render.Render) ([]FieldDiff, error)

type NormalizationRule

type NormalizationRule struct {
	Match      filter.MatchCriteria
	FieldPaths []filter.FieldPath
}

func GroupDiffsToRules

func GroupDiffsToRules(diffs []FieldDiff) []NormalizationRule

type ObjectRef

type ObjectRef struct {
	APIVersion string `json:"apiVersion"`
	Kind       string `json:"kind"`
	Name       string `json:"name"`
	Namespace  string `json:"namespace,omitempty"`
}

ObjectRef mirrors the Kubernetes ObjectReference shape.

type ResourceChange

type ResourceChange struct {
	LogicalID    string
	BeforeOrigin *render.Provenance
	AfterOrigin  *render.Provenance
	Cluster      string
	ID           resid.ResId
	Kind         string
	Name         string
	Namespace    string
	Provenance   render.Provenance
	Producer     string
	Action       string // added, deleted, modified
	Old          map[string]any
	New          map[string]any
	// contains filtered or unexported fields
}

ResourceChange describes a single resource change in a diff.

func (ResourceChange) UnifiedDiff

func (c ResourceChange) UnifiedDiff() string

UnifiedDiff returns the per-resource unified diff text for the change.

type ResultSummary

type ResultSummary struct {
	Total            int
	Clustered        bool
	Clusters         []string
	ByKind           map[string]int
	KindBreakdown    map[string]ChangeBreakdown
	ClusterBreakdown map[string]ChangeBreakdown
}

ResultSummary contains precomputed projections of a rendered manifest diff.

Jump to

Keyboard shortcuts

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