diff

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 25, 2021 License: UPL-1.0 Imports: 4 Imported by: 3

Documentation

Overview

Package diff provides utilities for diffing Kubernetes objects.

The utilities in this package are intended to be in used in the context of Kubernetes controllers, when comparing the live state of a Kubernetes object with its desired state.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Diff

func Diff(fromObject interface{}, toObject interface{}) string

Diff diffs two Golang objects recursively, but treats any elements whose values are empty in the 'fromObject' as "no diff". This is useful when comparing a desired Kubernetes object against a live Kubernetes object:

  1. The 'fromObject' is constructed via code, and doesn't specify a value for every nested field in the struct. Most Kubernetes object structs have an enormous number of fields, and it's not feasible to try to set them all when constructing the object. Also, note that some fields in the structs (like UUID, resourceVersion, or creationTime), are completely determined by Kubernetes at runtime.
  2. The 'toObject' has been retrieved via the Kubernetes API, and has had many of the fields that were unspecified in the fromObject populated with Kubernetes-generated values.

In this situation, to determine whether our fromObject is truly different than the toObject, we ignore processing of elements whose values are empty in the fromObject.

func IgnoreUnset

func IgnoreUnset() cmp.Option

Extended from https://github.com/kubernetes/apimachinery/blob/master/pkg/util/diff/diff.go IgnoreUnset return a cmp.Option to ignore changes for values that are unset in the toObject

Types

This section is empty.

Jump to

Keyboard shortcuts

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