kmp

package
v0.0.0-...-5dfa7fa Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package kmp wraps github.com/google/go-cmp with custom Comparers for frequently used kubernetes resources that have unexported fields.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareSetFields

func CompareSetFields(x, y interface{}, opts ...cmp.Option) ([]string, error)

CompareSetFields returns a list of field names that differ between x and y. Uses SafeEqual for comparison.

func SafeDiff

func SafeDiff(x, y interface{}, opts ...cmp.Option) (diff string, err error)

SafeDiff wraps cmp.Diff but recovers from panics and uses custom Comparers for: * k8s.io/apimachinery/pkg/api/resource.Quantity SafeDiff should be used instead of cmp.Diff in non-test code to protect the running process from crashing.

func SafeEqual

func SafeEqual(x, y interface{}, opts ...cmp.Option) (equal bool, err error)

SafeEqual wraps cmp.Equal but recovers from panics and uses custom Comparers for: * k8s.io/apimachinery/pkg/api/resource.Quantity SafeEqual should be used instead of cmp.Equal in non-test code to protect the running process from crashing.

func ShortDiff

func ShortDiff(prev, cur interface{}, opts ...cmp.Option) (string, error)

ShortDiff returns a zero-context, unified human-readable diff. Uses SafeEqual for comparison.

Types

type FieldListReporter

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

FieldListReporter implements the cmp.Reporter interface. It keeps track of the field names that differ between two structs and reports them through the Fields() function.

func (*FieldListReporter) Fields

func (r *FieldListReporter) Fields() []string

Fields returns the field names that differed between the two objects after calling cmp.Equal with the FieldListReporter. Field names are returned in alphabetical order.

func (*FieldListReporter) PopStep

func (r *FieldListReporter) PopStep()

PopStep implements cmp.Reporter.

func (*FieldListReporter) PushStep

func (r *FieldListReporter) PushStep(ps cmp.PathStep)

PushStep implements the cmp.Reporter.

func (*FieldListReporter) Report

func (r *FieldListReporter) Report(rs cmp.Result)

Report implements the cmp.Reporter.

type ShortDiffReporter

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

ShortDiffReporter implements the cmp.Reporter interface. It reports on fields which have diffing values in a short zero-context, unified diff format.

func (*ShortDiffReporter) Diff

func (r *ShortDiffReporter) Diff() (string, error)

Diff returns the generated short diff for this object. cmp.Equal should be called before this method.

func (*ShortDiffReporter) PopStep

func (r *ShortDiffReporter) PopStep()

PopStep implements the cmp.Reporter.

func (*ShortDiffReporter) PushStep

func (r *ShortDiffReporter) PushStep(ps cmp.PathStep)

PushStep implements the cmp.Reporter.

func (*ShortDiffReporter) Report

func (r *ShortDiffReporter) Report(rs cmp.Result)

Report implements the cmp.Reporter.

Jump to

Keyboard shortcuts

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