diff

package
v0.0.0-...-6b34a6b Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Diff

type Diff[T client.Object] struct {
	// contains filtered or unexported fields
}

Diff computes steps needed to bring a current state equal to a new state. Diff will add annotations to created and updated resources required for future diffing.

There are several O(N) or O(2N) operations; However, we expect N to be small.

func New

func New[T client.Object](current []T, want []Resource[T]) *Diff[T]

New creates a valid Diff.

func (*Diff[T]) Creates

func (diff *Diff[T]) Creates() []T

Creates returns a list of resources that should be created from scratch. Calls are memoized, so you can call this method multiple times without incurring additional cost. Adds labels and annotations on the resource to aid in future diffing.

func (*Diff[T]) Deletes

func (diff *Diff[T]) Deletes() []T

Deletes returns a list of resources that should be deleted. Calls are memoized, so you can call this method multiple times without incurring additional cost.

func (*Diff[T]) Updates

func (diff *Diff[T]) Updates() []T

Updates returns a list of resources that should be updated. Calls are memoized, so you can call this method multiple times without incurring additional cost.

type Resource

type Resource[T client.Object] interface {
	Object() T
	// Revision returns a unique identifier for the resource. A simple hash of the resource is sufficient.
	Revision() string
	// Ordinal returns the ordinal position of the resource. If order doesn't matter, return 0.
	Ordinal() int64
}

Resource is a diffable kubernetes object.

func Adapt

func Adapt[T client.Object, I constraints.Integer](obj T, ordinal I) Resource[T]

Adapt adapts a kubernetes client.Object into a diffable Resource which can be used by Diff. The revision is an FNV-1 hash of the object's JSON representation.

Jump to

Keyboard shortcuts

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