diff

package
v1.17.3 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package diff contains code for diffing sync-enabled resources, not necessarily known at compile time.

Index

Constants

View Source
const (
	// NoOp indicates that no action should be taken.
	NoOp = Operation("no-op")

	// Create indicates the resource should be created.
	Create = Operation("create")

	// Update indicates the resource is declared and is on the API server, so we should
	// calculate a patch and apply it.
	Update = Operation("update")

	// Delete indicates the resource should be deleted.
	Delete = Operation("delete")

	// Error indicates the resource's management annotation in the API server is invalid.
	Error = Operation("error")

	// Abandon indicates the resource's management annotation should be removed from the API Server.
	Abandon = Operation("abandon")

	// ManagementConflict represents the case where Declared and Actual both exist,
	// but the Actual one is managed by a Reconciler that supersedes this one.
	ManagementConflict = Operation("management-conflict")
)
View Source
const (

	// OperationManage is a meta operation that implies full control:
	// CREATE + UPDATE + DELETE
	OperationManage = admissionv1.Operation("MANAGE")
)

Variables

This section is empty.

Functions

func CanManage

func CanManage(scope declared.Scope, syncName string, obj client.Object, op admissionv1.Operation) bool

CanManage returns true if the given reconciler is allowed to perform the specified operation on the specified resource object.

func IsManager

func IsManager(scope declared.Scope, syncName string, obj client.Object) bool

IsManager returns true if the given reconciler is the manager for the resource.

func IsUnknown

func IsUnknown(obj client.Object) bool

IsUnknown returns true if the given Object is the sentinel marker of unknown state on the cluster.

func Unknown

func Unknown() client.Object

Unknown returns a sentinel Object which represents unknown state on the cluster. On failing to retrieve the current state of an Object on the cluster, a caller should use this to indicate that no action should be taken to reconcile the declared version of an Object.

func ValidateManager

func ValidateManager(reconciler, manager string, id core.ID, op admissionv1.Operation) error

ValidateManager returns nil if the given reconciler is allowed to perform the specified operation on the resource object with the specified id.

It's not possible to parse a ReconcilerName into its component parts, because R*Sync names and namespaces may include a dash, which is used as the delimiter. But you CAN parse a manager name into scope (namespace) and name, and use that to build a reconciler name. So we have to compare reconciler names instead of manager names.

Types

type Diff

type Diff struct {
	// Declared is the resource as it exists in the repository.
	Declared client.Object
	// Actual is the resource as it exists in the cluster.
	Actual client.Object
}

Diff is resource where Declared and Actual do not match. Both Declared and Actual are client.Object.

func ThreeWay

func ThreeWay(newDeclared, previousDeclared, actual map[core.ID]client.Object) []Diff

ThreeWay does a three way diff and returns the FileObjectDiff list. Compare between previous declared and new declared to decide the delete list. Compare between the new declared and the actual states to decide the create and update.

func (*Diff) GetName

func (d *Diff) GetName() string

GetName returns the metadata.name of the object being considered.

func (Diff) Operation

func (d Diff) Operation(scope declared.Scope, syncName string) Operation

Operation returns the type of the difference between the repository and the API Server.

func (Diff) UnstructuredActual

func (d Diff) UnstructuredActual() (*unstructured.Unstructured, status.Error)

UnstructuredActual returns the actual as an unstructured object.

func (Diff) UnstructuredDeclared

func (d Diff) UnstructuredDeclared() (*unstructured.Unstructured, status.Error)

UnstructuredDeclared returns the declared as an unstructured object.

type Operation

type Operation string

Operation indicates what action should be taken if we detect a difference between declared configuration and the state of the cluster.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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