Documentation
¶
Index ¶
- func ToUnstructured(obj runtime.Object) (*unstructured.Unstructured, error)
- type Helper
- func (h *Helper) GetAfter() *unstructured.Unstructured
- func (h *Helper) GetBefore() *unstructured.Unstructured
- func (h *Helper) GetBeforeObject() client.Object
- func (h *Helper) GetChanges() map[string]bool
- func (h *Helper) GetClient() client.Client
- func (h *Helper) GetFinalizer() string
- func (h *Helper) GetGKV() schema.GroupVersionKind
- func (h *Helper) GetKClient() kubernetes.Interface
- func (h *Helper) GetLogger() logr.Logger
- func (h *Helper) GetScheme() *runtime.Scheme
- func (h *Helper) PatchInstance(ctx context.Context, instance client.Object) error
- func (h *Helper) SetAfter(obj client.Object) error
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 ¶
GetBeforeObject - returns the object before modification
func (*Helper) GetChanges ¶
GetChanges - returns unstructured object after modification
func (*Helper) GetFinalizer ¶
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) PatchInstance ¶
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 } } ... }