helper

package
v0.0.0-...-23d2596 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToUnstructured

func ToUnstructured(obj runtime.Object) (*unstructured.Unstructured, error)

ToUnstructured - convert to unstructured

Types

type Helper

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

Helper is a utility for ensuring the proper patching of objects.

func NewHelper

func NewHelper(obj client.Object, crClient client.Client, kclient kubernetes.Interface, scheme *runtime.Scheme, log logr.Logger) (*Helper, error)

NewHelper returns an initialized Helper.

func (*Helper) GetAfter

func (h *Helper) GetAfter() *unstructured.Unstructured

GetAfter - returns unstructured object after modification

func (*Helper) GetBefore

func (h *Helper) GetBefore() *unstructured.Unstructured

GetBefore - returns unstructured object after modification

func (*Helper) GetBeforeObject

func (h *Helper) GetBeforeObject() client.Object

GetBeforeObject - returns the object before modification

func (*Helper) GetChanges

func (h *Helper) GetChanges() map[string]bool

GetChanges - returns unstructured object after modification

func (*Helper) GetClient

func (h *Helper) GetClient() client.Client

GetClient - returns the client

func (*Helper) GetFinalizer

func (h *Helper) GetFinalizer() string

GetFinalizer - returns the finalizer

func (*Helper) GetGKV

func (h *Helper) GetGKV() schema.GroupVersionKind

GetGKV - returns the GKV of the object

func (*Helper) GetKClient

func (h *Helper) GetKClient() kubernetes.Interface

GetKClient - returns the kclient

func (*Helper) GetLogger

func (h *Helper) GetLogger() logr.Logger

GetLogger - returns the logger

func (*Helper) GetScheme

func (h *Helper) GetScheme() *runtime.Scheme

GetScheme - returns the runtime scheme of the object

func (*Helper) PatchInstance

func (h *Helper) PatchInstance(ctx context.Context, instance client.Object) error

PatchInstance - Patch an instance's metadata and/or status if they have changed (based on comparison with its old state as represented in the helper.Helper)

NOTE: This function is mainly intended for use in Podified Operators with their deferred-instance-persistence pattern within the reconcile loop. If used in this manner, any error returned by this function should be set as the error returned by the encompassing Reconcile(...) function so that the error from PatchInstance is properly propagated.

Example:

func (r *SomeReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, _err error) {
    ...
    defer func() {
        ...
        err := instance.PatchInstance(ctx, h, instance)
        if err != nil {
            _err = err
            return
        }
    }
    ...
}

func (*Helper) SetAfter

func (h *Helper) SetAfter(obj client.Object) error

SetAfter - returns the logger

Jump to

Keyboard shortcuts

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