diff

package
v0.48.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("not found")
)

Functions

func RenderByCommand added in v0.48.0

func RenderByCommand(command string, old, new interface{}) ([]byte, error)

RenderByCommand converts the given objects into yaml and then runs the command to compare them.

func RenderPrimitiveValue

func RenderPrimitiveValue(v reflect.Value) string

Types

type Node

type Node struct {
	Path       []PathStep
	PathString string
	TypeX      reflect.Type
	TypeY      reflect.Type
	ValueX     reflect.Value
	ValueY     reflect.Value
}

func (Node) StringX

func (n Node) StringX() string

func (Node) StringY

func (n Node) StringY() string

type Nodes

type Nodes []Node

func (Nodes) Find

func (ns Nodes) Find(query string) (Nodes, error)

func (Nodes) FindByPrefix

func (ns Nodes) FindByPrefix(prefix string) Nodes

func (Nodes) FindOne

func (ns Nodes) FindOne(query string) (*Node, error)

type Option

type Option func(*differ)

func WithCompareNumberAndNumericString

func WithCompareNumberAndNumericString() Option

WithCompareNumberAndNumericString configures differ to compare a number with a numeric string. Differ parses the string to number before comparing their values. e.g. 1.5 == "1.5"

func WithEquateEmpty

func WithEquateEmpty() Option

WithEquateEmpty configures differ to consider all maps/slides with a length of zero and nil to be equal.

func WithIgnoreAddingMapKeys

func WithIgnoreAddingMapKeys() Option

WithIgnoreAddingMapKeys configures differ to ignore all map keys that were added to the second object and missing in the first one.

func WithIgnoreConfig added in v0.43.0

func WithIgnoreConfig(config map[string][]string) Option

WithIgnoreConfig configures ignored fields.

type PathStep

type PathStep struct {
	Type       PathStepType
	MapIndex   string
	SliceIndex int
}

func (PathStep) String

func (s PathStep) String() string

type PathStepType

type PathStepType string
const (
	MapIndexPathStep   PathStepType = "MapIndex"
	SliceIndexPathStep PathStepType = "SliceIndex"
)

type RenderOption

type RenderOption func(*Renderer)

func WithLeftPadding

func WithLeftPadding(p int) RenderOption

func WithMaskPath

func WithMaskPath(prefix string) RenderOption

type Renderer

type Renderer struct {
	// contains filtered or unexported fields
}

func NewRenderer

func NewRenderer(opts ...RenderOption) *Renderer

func (*Renderer) Render

func (r *Renderer) Render(ns Nodes) string

type Result

type Result struct {
	// contains filtered or unexported fields
}

func DiffStructureds added in v0.48.0

func DiffStructureds(x, y interface{}, opts ...Option) (*Result, error)

DiffStructureds calulates the diff between non-k8s manifests. If you compare k8s manifests, use DiffUnstructureds instead.

func DiffUnstructureds

func DiffUnstructureds(x, y unstructured.Unstructured, key string, opts ...Option) (*Result, error)

DiffUnstructureds calculates the diff between two unstructured objects. If you compare non-k8s manifests, use DiffStructureds instead.

func (*Result) HasDiff

func (r *Result) HasDiff() bool

func (*Result) Nodes

func (r *Result) Nodes() Nodes

func (*Result) NumNodes

func (r *Result) NumNodes() int

Jump to

Keyboard shortcuts

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