recutil

package
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventRequestStart = "ReconcileRequestStart"
	EventNotFound     = "ReconcileNotFound"
	EventStart        = "ReconcileStart"
	EventSkipped      = "ReconcileSkipped"
	EventRequeued     = "ReconcileRequeued"
	EventError        = "ReconcileError"
	EventComplete     = "ReconcileComplete"
)

Variables

This section is empty.

Functions

func ResolveAndReconcile

func ResolveAndReconcile(ctx context.Context, logger logr.Logger, mgr manager.Manager, objType runtime.Object, inner ObjectReconcileFunc) reconcile.Reconciler

ResolveAndReconcile helps avoid boilerplate where you would normally attempt to fetch your modified object at the start of a reconciliation loop, and instead calls an inner reconciliation function with the already resolved object.

Types

type DiffFunc

type DiffFunc func(runtime.Object, runtime.Object) Outcome

DiffFunc takes two Kubernetes resources: expected and existing. Both are assumed to be the same Kind. It compares the two, and returns an Outcome indicating how to transition from existing to expected. If an update is required, it will set the relevant fields on existing to their intended values. This is so that we can simply resubmit the existing resource, and any fields automatically set by the Kubernetes API server will be retained.

type ObjWithMeta

type ObjWithMeta interface {
	metav1.Object
	runtime.Object
}

ObjWithMeta describes a Kubernetes resource with a metadata field. It's a combination of two common existing Kubernetes interfaces. We do this because we want to use methods from each in CreateOrUpdate, whilst still keeping the argument type generic.

type ObjectReconcileFunc

type ObjectReconcileFunc func(logger logr.Logger, request reconcile.Request, obj runtime.Object) (reconcile.Result, error)

ObjectReconcileFunc defines the expected interface for the reconciliation of a single object type- it can be used to avoid boilerplate for finding and initializing objects at the start of traditional reconciliation loops.

type Outcome

type Outcome string

Outcome describes the operation performed by CreateOrUpdate.

const (
	Create Outcome = "create"
	Update Outcome = "update"
	None   Outcome = "none"
	Error  Outcome = "error"
)

func CreateOrUpdate

func CreateOrUpdate(ctx context.Context, c client.Client, existing ObjWithMeta, diffFunc DiffFunc) (Outcome, error)

CreateOrUpdate takes a Kubernetes object and a "diff function" and attempts to ensure that the the object exists in the cluster with the correct state. It will use the diff function to determine any differences between the cluster state and the local state and use that to decide how to update it.

func DirectoryRoleBindingDiff

func DirectoryRoleBindingDiff(expectedObj runtime.Object, existingObj runtime.Object) Outcome

DirectoryRoleBindingDiff is a DiffFunc for DirectoryRoleBindings

func RoleDiff

func RoleDiff(expectedObj runtime.Object, existingObj runtime.Object) Outcome

RoleDiff is a DiffFunc for Roles

Jump to

Keyboard shortcuts

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