diff

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Schema is the standard profile used for comparing schema.
	Schema = &Profile{}

	// Final is the standard profile for comparing data.
	Final = &Profile{
		Concrete: true,
	}
)

Functions

func Diff

func Diff(x, y cue.Value) (Kind, *EditScript)

Diff is a shorthand for Schema.Diff.

func Print

func Print(w io.Writer, es *EditScript) error

Print the differences between two structs represented by an edit script.

Types

type Edit

type Edit struct {
	Kind Kind
	XSel cue.Selector // valid if UniqueY
	YSel cue.Selector // valid if UniqueX
	Sub  *EditScript  // non-nil if Modified
}

Edit represents a single operation within an edit-script.

type EditScript

type EditScript struct {
	X, Y  cue.Value
	Edits []Edit
}

EditScript represents the series of differences between two CUE values. x and y must be either both list or struct.

type Kind

type Kind uint8

Kind identifies the kind of operation of an edit script.

const (
	// Identity indicates that a value pair is identical in both list X and Y.
	Identity Kind = iota
	// UniqueX indicates that a value only exists in X and not Y.
	UniqueX
	// UniqueY indicates that a value only exists in Y and not X.
	UniqueY
	// Modified indicates that a value pair is a modification of each other.
	Modified
)

type Profile added in v0.1.0

type Profile struct {
	Concrete bool

	// Hidden fields are only useful to compare when a values are from the same
	// package.
	SkipHidden bool
}

Profile configures a diff operation.

func (*Profile) Diff added in v0.1.0

func (p *Profile) Diff(x, y cue.Value) (Kind, *EditScript)

Diff returns an edit script representing the difference between x and y.

Jump to

Keyboard shortcuts

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