diff

package
v1.0.70 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 8 Imported by: 2 modules, 1 package

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

View Source
const (
	// ModChange leaf's value is being updated
	ModChange = ModificationType("Change")
	// ModDelete node is being removed
	ModDelete = ModificationType("Delete")
	// ModAdd leaf value is being added
	ModAdd = ModificationType("Add")
)

Variables

This section is empty.

Functions

func Apply

func Apply(node dom.ContainerBuilder, mods []Modification)

func DefaultLeafDiffFn added in v1.0.70

func DefaultLeafDiffFn(ctx DifferContext, left, right dom.Leaf, pb path.Builder)

DefaultLeafDiffFn compares leaf values using go-cmp's Equals()

func DefaultListDiffFn added in v1.0.69

func DefaultListDiffFn(ctx DifferContext, left, right dom.List, pb path.Builder)

DefaultListDiffFn drops right list and flatten left one into series of additions.

func Diff

func Diff(left, right dom.Container, opts ...Opt) *[]Modification

Diff computes difference between 2 Containers

func K8sListDiffFn added in v1.0.69

func K8sListDiffFn(ctx DifferContext, left, right dom.List, pb path.Builder)

func OverlayDocs added in v1.0.59

func OverlayDocs(left, right dom.OverlayDocument, opts ...Opt) map[string]*[]Modification

OverlayDocs computes semantic difference between 2 Overlay documents

func TrimStringLeafDiffFn added in v1.0.70

func TrimStringLeafDiffFn(ctx DifferContext, left, right dom.Leaf, pb path.Builder)

TrimStringLeafDiffFn trims leading and trailing whitespace from string value before comparing. Both leaves must be string, otherwise comparison is delegated to default comparing function

Types

type DifferContext added in v1.0.67

type DifferContext interface {
	// Append appends modification to the result slice
	Append(mt ModificationType, p path.Path, oldVal, newVal any)
	// Flatten flattens out Node into sequence of Modifications.
	Flatten(node dom.Node, pb path.Builder)
	// ListDiff compares 2 lists and generates list of modification from their difference using provided function
	ListDiff(left, right dom.List, pb path.Builder, fn ListDiffFn)

	ContainerDiff(left, right dom.Container, pb path.Builder)
}

type LeafDiffFn added in v1.0.70

type LeafDiffFn func(ctx DifferContext, left, right dom.Leaf, pb path.Builder)

type ListDiffFn added in v1.0.67

type ListDiffFn func(ctx DifferContext, left, right dom.List, pb path.Builder)

type Modification

type Modification struct {
	Type     ModificationType `yaml:"type"`
	Path     path.Path        `yaml:"path"`
	Value    any              `yaml:"value,omitempty"`
	OldValue any              `yaml:"oldValue,omitempty"`
}

func (*Modification) String

func (m *Modification) String() string

type ModificationType

type ModificationType string

type Opt added in v1.0.67

type Opt func(*differ)

func WithLeafDiffFn added in v1.0.70

func WithLeafDiffFn(fn LeafDiffFn) Opt

func WithListDiffFn added in v1.0.67

func WithListDiffFn(fn ListDiffFn) Opt

Jump to

Keyboard shortcuts

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