patcher

package
v0.23.0-alpha.6 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyObject

func ApplyObject(ctx *synccontext.SyncContext, beforeObject, afterObject client.Object, direction synccontext.SyncDirection, hasStatus bool) error

func ApplyObjectPatch

func ApplyObjectPatch(ctx *synccontext.SyncContext, objPatch patch.Patch, obj client.Object, direction synccontext.SyncDirection, hasStatus bool) error

func CopyBidirectional

func CopyBidirectional[T any](virtualOld, virtual, hostOld, host T) (T, T)

CopyBidirectional determines whether the change is in the virtual or host object by seeing what changed between "old" and "new" for each. It then mutates the changed object to match the unchanged object.

func CreateHostObject

func CreateHostObject(ctx *synccontext.SyncContext, vObj, pObj client.Object, eventRecorder record.EventRecorder, hasStatus bool) (ctrl.Result, error)

func CreateVirtualObject

func CreateVirtualObject(ctx *synccontext.SyncContext, pObj, vObj client.Object, eventRecorder record.EventRecorder, hasStatus bool) (ctrl.Result, error)

func DeleteHostObject

func DeleteHostObject(ctx *synccontext.SyncContext, pObj, vObjOld client.Object, reason string) (ctrl.Result, error)

func DeleteHostObjectWithOptions

func DeleteHostObjectWithOptions(ctx *synccontext.SyncContext, pObj, vObjOld client.Object, reason string, options *client.DeleteOptions) (ctrl.Result, error)

func DeleteVirtualObject

func DeleteVirtualObject(ctx *synccontext.SyncContext, vObj, pObjOld client.Object, reason string) (ctrl.Result, error)

func DeleteVirtualObjectWithOptions

func DeleteVirtualObjectWithOptions(ctx *synccontext.SyncContext, vObj, pObjOld client.Object, reason string, options *client.DeleteOptions) (ctrl.Result, error)

func MergeBidirectional

func MergeBidirectional[T any](virtualOld, virtual, hostOld, host T) (T, T, error)

MergeBidirectional determines whether the change is in the virtual or host object by seeing what changed between "old" and "new" for each. It then merges the changes from the changed object into the unchanged object by marshalling them and using a json merge patch on the unchanged object.

func MergeChangesInto

func MergeChangesInto[T any](oldValue, newValue, outValue T) (T, error)

MergeChangesInto merges changes from "newValue" into "outValue" based on the changes between "oldValue" and "newValue".

Types

type Option

type Option interface {
	Apply(p *Patcher)
}

func NoStatusSubResource

func NoStatusSubResource() Option

func TranslatePatches

func TranslatePatches(translate []config.TranslatePatch, reverseExpressions bool) Option

type Patcher

type Patcher struct {
	NoStatusSubResource bool
	// contains filtered or unexported fields
}

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

func NewPatcher

func NewPatcher(obj client.Object, crClient client.Client, options ...Option) (*Patcher, error)

NewPatcher returns an initialized Patcher.

func (*Patcher) Patch

func (h *Patcher) Patch(ctx *synccontext.SyncContext, obj client.Object) error

Patch will attempt to patch the given object, including its status.

type SyncerPatcher

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

func NewSyncerPatcher

func NewSyncerPatcher(ctx *synccontext.SyncContext, pObj, vObj client.Object, options ...Option) (*SyncerPatcher, error)

func (*SyncerPatcher) Patch

func (h *SyncerPatcher) Patch(ctx *synccontext.SyncContext, pObj, vObj client.Object) error

Patch will attempt to patch the given object, including its status.

Jump to

Keyboard shortcuts

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