diff

package
v0.0.0-...-192ee93 Latest Latest
Warning

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

Go to latest
Published: May 15, 2020 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTwoWayMergePatch

func CreateTwoWayMergePatch(orig, new, dataStruct interface{}) ([]byte, bool, error)

CreateTwoWayMergePatch is a helper to construct a two-way merge patch from objects (instead of bytes)

func GetLastAppliedConfigAnnotation

func GetLastAppliedConfigAnnotation(live *unstructured.Unstructured) *unstructured.Unstructured

func HideSecretData

HideSecretData replaces secret data values in specified target, live secrets and in last applied configuration of live secret with stars. Also preserves differences between target, live and last applied config values. E.g. if all three are equal the values would be replaced with same number of stars. If all the are different then number of stars in replacement should be different.

func Normalize

func Normalize(un *unstructured.Unstructured, normalizer Normalizer, options DiffOptions)

func NormalizeSecret

func NormalizeSecret(un *unstructured.Unstructured)

NormalizeSecret mutates the supplied object and encodes stringData to data, and converts nils to empty strings. If the object is not a secret, or is an invalid secret, then returns the same object.

func PrintDiff

func PrintDiff(name string, live *unstructured.Unstructured, target *unstructured.Unstructured) error

PrintDiff prints a diff between two unstructured objects to stdout using an external diff utility Honors the diff utility set in the KUBECTL_EXTERNAL_DIFF environment variable

Types

type DiffOptions

type DiffOptions struct {
	IgnoreAggregatedRoles bool `json:"ignoreAggregatedRoles,omitempty"`
}

func GetDefaultDiffOptions

func GetDefaultDiffOptions() DiffOptions

Returns the default diff options

type DiffResult

type DiffResult struct {
	// Deprecated: Use PredictedLive and NormalizedLive instead
	Diff           gojsondiff.Diff
	Modified       bool
	PredictedLive  []byte
	NormalizedLive []byte
}

func Diff

func Diff(config, live *unstructured.Unstructured, normalizer Normalizer, options DiffOptions) (*DiffResult, error)

Diff performs a diff on two unstructured objects. If the live object happens to have a "kubectl.kubernetes.io/last-applied-configuration", then perform a three way diff.

func ThreeWayDiff

func ThreeWayDiff(orig, config, live *unstructured.Unstructured) (*DiffResult, error)

ThreeWayDiff performs a diff with the understanding of how to incorporate the last-applied-configuration annotation in the diff. Inputs are assumed to be stripped of type information

func TwoWayDiff

func TwoWayDiff(config, live *unstructured.Unstructured) (*DiffResult, error)

TwoWayDiff performs a three-way diff and uses specified config as a recently applied config

func (*DiffResult) JSONFormat

func (d *DiffResult) JSONFormat() (string, error)

JSONFormat returns the diff as a JSON string

type DiffResultList

type DiffResultList struct {
	Diffs    []DiffResult
	Modified bool
}

func DiffArray

func DiffArray(configArray, liveArray []*unstructured.Unstructured, normalizer Normalizer, options DiffOptions) (*DiffResultList, error)

DiffArray performs a diff on a list of unstructured objects. Objects are expected to match environments

type Normalizer

type Normalizer interface {
	Normalize(un *unstructured.Unstructured) error
}

Jump to

Keyboard shortcuts

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