Documentation ¶
Overview ¶
Package v1 provides helpers to build a sync controller. It defines a Controller interface which provides methods required for reconciling a sync controller. The package also provides an implementation of the Reconcile method that can be embedded in a controller to satisfy the controller-runtime's Reconciler interface. It supports plugging in sync functions that run as go routines and help with keeping the systems in sync.
Index ¶
- type Controller
- type Reconciler
- type ReconcilerOption
- func WithClient(cli client.Client) ReconcilerOption
- func WithInstrumentation(tp trace.TracerProvider, mp metric.MeterProvider, log logr.Logger) ReconcilerOption
- func WithName(name string) ReconcilerOption
- func WithPrototype(obj client.Object) ReconcilerOption
- func WithScheme(scheme *runtime.Scheme) ReconcilerOption
- func WithSyncFuncs(sf []SyncFunc) ReconcilerOption
- type SyncFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller interface { // Ensure receives a k8s object and calls an external system's API to // ensure an associated object exists in the external system. Based on the // use case, it may also update the object in the external system to have // the same the desired configuration. Ensure(context.Context, client.Object) error // Delete receives a k8s object that's deleted and calls an external // system's API to delete the associated object in the external system. Delete(context.Context, client.Object) error }
Controller is an object sync controller interface that must be implemented by an object sync controller. It provides methods required for reconciling and syncing objects.
type Reconciler ¶
type Reconciler struct { Name string Ctrlr Controller Prototype client.Object PrototypeList client.ObjectList Client client.Client Scheme *runtime.Scheme SyncFuncs []SyncFunc Inst *telemetry.Instrumentation }
Reconciler defines a sync reconciler.
func (*Reconciler) Init ¶
func (s *Reconciler) Init(mgr ctrl.Manager, ctrlr Controller, prototype client.Object, prototypeList client.ObjectList, opts ...ReconcilerOption) error
Init initializes the Reconciler for a given Object with the given options.
func (*Reconciler) RunSyncFuncs ¶
func (s *Reconciler) RunSyncFuncs()
RunSyncFuncs runs all the SyncFuncs in go routines.
type ReconcilerOption ¶
type ReconcilerOption func(*Reconciler)
ReconcilerOption is used to configure Reconciler.
func WithClient ¶
func WithClient(cli client.Client) ReconcilerOption
WithClient sets the k8s client in the reconciler.
func WithInstrumentation ¶
func WithInstrumentation(tp trace.TracerProvider, mp metric.MeterProvider, log logr.Logger) ReconcilerOption
WithInstrumentation configures the instrumentation of the Reconciler.
func WithName ¶
func WithName(name string) ReconcilerOption
WithName sets the name of the Reconciler.
func WithPrototype ¶
func WithPrototype(obj client.Object) ReconcilerOption
WithPrototype sets a prototype of the object that's reconciled.
func WithScheme ¶
func WithScheme(scheme *runtime.Scheme) ReconcilerOption
WithScheme sets the runtime Scheme of the Reconciler.
func WithSyncFuncs ¶
func WithSyncFuncs(sf []SyncFunc) ReconcilerOption
WithSyncFuncs sets the syncFuncs of the Reconciler.
type SyncFunc ¶
type SyncFunc struct {
// contains filtered or unexported fields
}
SyncFunc defines a sync function with a sync period.
func NewSyncFunc ¶
NewSyncFunc returns a new SyncFunc, given a function and a sync period.