reconciler

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2025 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package reconciler provides the core reconciliation abstractions for Δ-controller sources and targets, implementing the bridge between Kubernetes resources and the controller pipeline.

This package handles the complexity of watching Kubernetes resources, converting them to controller requests, and writing results back to target resources. It supports both native Kubernetes resources and view objects with consistent semantics.

Key components:

  • Source: Configurable watch source with label/field selector support.
  • Target: Configurable write target with Updater/Patcher semantics.
  • Resource: Base abstraction for Kubernetes resource types.
  • Request: Reconciliation request with event metadata.

Sources support:

  • Multiple resource types (native Kubernetes and views).
  • Label and field selectors for filtering.
  • Configurable predicates for change detection.
  • Namespace-scoped and cluster-scoped resources.

Targets support:

  • Updater: Replaces target object content completely.
  • Patcher: Applies strategic merge patches to target objects.

Example usage:

source := reconciler.NewSource(mgr, "my-op", opv1a1.Source{
    Resource: opv1a1.Resource{Kind: "Pod"},
    LabelSelector: &metav1.LabelSelector{...},
})

target := reconciler.NewTarget(mgr, "my-op", opv1a1.Target{
    Resource: opv1a1.Resource{Kind: "PodView"},
    Type: "Patcher",
})

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateOrUpdate

CreateOrUpdate creates or updates the given object in the Kubernetes cluster. The object's desired state must be reconciled with the existing state inside the passed in callback MutateFn.

The MutateFn is called regardless of creating or updating an object.

It returns the executed operation and an error.

Note: this version differs from default controllerutil.CreateOrUpdate in two subtle ways

  • it uses the unstructured API via object.Object,
  • changes made by MutateFn to the status subresource will be handled, changes to any other sub-resource will be discarded,
  • errors produced by the `Create` branch (after a failed `Get`) will be ignored.

Types

type EventHandler

type EventHandler[object client.Object] struct {
	// contains filtered or unexported fields
}

func (EventHandler[O]) Create

Create createa a "create" event.

func (EventHandler[O]) Delete

Delete creates a "deletion" event.

func (EventHandler[O]) Generic

Generic create a generic event/

func (EventHandler[O]) Update

Update createa an "update" event.

type Reconciler

type Reconciler = reconcile.TypedReconciler[Request]

type Request

type Request struct {
	Namespace, Name string
	EventType       object.DeltaType
	GVK             schema.GroupVersionKind
}

Definition of a reconciliation request.

func (*Request) String

func (r *Request) String() string

String stringifies a reconciliation request.

type Resource

type Resource interface {
	fmt.Stringer
	// GetGVK returns the GVK for a resource.
	GetGVK() (schema.GroupVersionKind, error)
}

Resource defines a generic resource, either a source or a target.

func NewResource

func NewResource(mgr runtimeManager.Manager, operator string, r opv1a1.Resource) Resource

NewResource creates a new resource.

type Source

type Source interface {
	Resource
	GetSource() (runtimeSource.TypedSource[Request], error)
	fmt.Stringer
}

Source is a generic watch source that knows how to create controller runtime sources.

func NewSource

func NewSource(mgr runtimeManager.Manager, operator string, s opv1a1.Source) Source

NewSource creates a new source resource.

type Target

type Target interface {
	Resource
	Write(context.Context, object.Delta) error
	fmt.Stringer
}

Target is a generic writer that knows how to create controller runtime objects in a target resource.

func NewTarget

func NewTarget(mgr runtimeManager.Manager, operator string, t opv1a1.Target) Target

NewTarget creates a new target resource.

Jump to

Keyboard shortcuts

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