utils

package
v0.0.0-...-e1524c0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DelayedRequeue

func DelayedRequeue() (ctrl.Result, error)

Trigger a reschedule after a short delay.

func EndReconciliation

func EndReconciliation() (ctrl.Result, error)

Don't trigger a reschedule, we're done.

func GetImageName

func GetImageName(name string) string

Compute the full Image name

func Requeue

func Requeue(err error) (ctrl.Result, error)

Trigger a reschedule as soon as possible.

func SetVersionLabel

func SetVersionLabel(object metav1.Object, version string)

Set version labels on an Object, default to the MetalK8s version

func UpdateAnnotations

func UpdateAnnotations(object metav1.Object, annotations map[string]string)

Update annotations on an Object

func UpdateLabels

func UpdateLabels(object metav1.Object, labels map[string]string)

Update labels on an Object

Types

type ObjectHandler

type ObjectHandler struct {
	// The client used to interact with the APIServer
	Client client.Client
	// contains filtered or unexported fields
}

Struct used to manage Kubernetes objects creation, update and deletion that allow to use a single entry point to manage various objects and properly log actions and add some standard metadata

func NewObjectHandler

func NewObjectHandler(instance client.Object, client client.Client, scheme *runtime.Scheme, recorder record.EventRecorder, logger logr.Logger, component string, name string) *ObjectHandler

Initiate an ObjectHandler struct

func (ObjectHandler) CreateOrUpdateOrDelete

func (h ObjectHandler) CreateOrUpdateOrDelete(ctx context.Context, objsToUpdate []client.Object, objsToDelete []client.Object, mutate func(client.Object) error) (bool, error)

Create, Update or delete objects so that it match desired object from args return wether or not some objects get changed (Created, Updated, Deleted) NOTE: The objsToUpdate contains the objects to Update and to Create NOTE: This function will call the mutate function on every objects to Update (check controllerutil.CreateOrUpdate for more information) NOTE: (To keep in mind) This function will Create, Update, Delete all objects in a single call (so in a single Reconcile loop) but stop on the first error

func (ObjectHandler) GetMatchingLabels

func (h ObjectHandler) GetMatchingLabels(includeVersion bool) client.MatchingLabels

Get Standard Labels matcher that can be used to list objects

func (ObjectHandler) SendEvent

func (h ObjectHandler) SendEvent(status metav1.ConditionStatus, reason string, message string)

Send an event to the instance

type SubReconciler

type SubReconciler interface {
	Load(*ObjectHandler, logr.Logger, *metalk8sscalitycomv1alpha1.ClusterConfig)
	GetLogger() logr.Logger
	Reconcile(context.Context) SubReconcilerResult
}

Interface for all SubReconciler

type SubReconcilerResult

type SubReconcilerResult struct {
	// contains filtered or unexported fields
}

func NeedDelayedRequeue

func NeedDelayedRequeue() SubReconcilerResult

A delayed requeue is needed

func NeedEndReconciliation

func NeedEndReconciliation() SubReconcilerResult

End the reconciliation

func NeedRequeue

func NeedRequeue(err error) SubReconcilerResult

A requeue is needed

func NothingToDo

func NothingToDo() SubReconcilerResult

Nothing to do, reconcilitation can continue

func (SubReconcilerResult) GetResult

func (r SubReconcilerResult) GetResult() (ctrl.Result, error)

Get the Return for the main Reconcile function

func (SubReconcilerResult) IsSuperior

func (r SubReconcilerResult) IsSuperior(r2 SubReconcilerResult) bool

Compare if it's more important result

func (SubReconcilerResult) ShouldReturn

func (r SubReconcilerResult) ShouldReturn() bool

Return wether or not the main Reconcile function should return

Jump to

Keyboard shortcuts

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