Documentation
¶
Index ¶
- Constants
- func AcceptedCondition(p exttypes.Policy, err error) *metav1.Condition
- func ConditionMarshal(conditions []metav1.Condition) ([]byte, error)
- func EnforcedCondition(p exttypes.Policy, err error, fully bool) *metav1.Condition
- func Resolve[T any](ctx context.Context, kuadrantCtx exttypes.KuadrantCtx, policy exttypes.Policy, ...) (T, error)
- type Builder
- func (b *Builder) Build() (*ExtensionController, error)
- func (b *Builder) For(obj client.Object) *Builder
- func (b *Builder) Owns(obj client.Object) *Builder
- func (b *Builder) Watches(obj client.Object) *Builder
- func (b *Builder) WithReconciler(fn exttypes.ReconcileFn) *Builder
- func (b *Builder) WithScheme(scheme *runtime.Scheme) *Builder
- type EventCachingHandler
- func (h *EventCachingHandler) Create(_ context.Context, event ctrlruntimeevent.TypedCreateEvent[client.Object], ...)
- func (h *EventCachingHandler) Delete(_ context.Context, event ctrlruntimeevent.TypedDeleteEvent[client.Object], ...)
- func (h *EventCachingHandler) Generic(_ context.Context, event ctrlruntimeevent.TypedGenericEvent[client.Object], ...)
- func (h *EventCachingHandler) Update(_ context.Context, event ctrlruntimeevent.TypedUpdateEvent[client.Object], ...)
- type EventTypeCache
- type ExtensionConfig
- type ExtensionController
- func (ec *ExtensionController) AddDataTo(ctx context.Context, policy exttypes.Policy, domain exttypes.Domain, ...) error
- func (ec *ExtensionController) ClearPolicy(ctx context.Context, namespace, name, kind string) error
- func (ec *ExtensionController) Manager() ctrlruntime.Manager
- func (ec *ExtensionController) Reconcile(ctx context.Context, request reconcile.Request) (reconcile.Result, error)
- func (ec *ExtensionController) ReconcileObject(ctx context.Context, obj client.Object, desired client.Object, ...) (client.Object, error)
- func (ec *ExtensionController) Resolve(ctx context.Context, policy exttypes.Policy, expression string, subscribe bool) (ref.Val, error)
- func (ec *ExtensionController) ResolvePolicy(ctx context.Context, policy exttypes.Policy, expression string, subscribe bool) (exttypes.Policy, error)
- func (ec *ExtensionController) Start(ctx context.Context) error
- func (ec *ExtensionController) Subscribe(ctx context.Context, reconcileChan chan ctrlruntimeevent.GenericEvent)
Constants ¶
const ( EventTypeCreate = "CREATE" EventTypeUpdate = "UPDATE" EventTypeDelete = "DELETE" EventTypeGeneric = "GENERIC" EventTypeUnknown = "UNKNOWN" )
Event type constants cached to attribute the triggering reason for a reconcile request when it is later processed.
const ( // ExtensionFinalizer is added to extension managed policies so that final // cleanup (e.g. mutator/subscription deregistration) can occur prior to // object deletion. ExtensionFinalizer = "kuadrant.io/extensions" )
Variables ¶
This section is empty.
Functions ¶
func AcceptedCondition ¶
AcceptedCondition returns a metav1.Condition reflecting the accepted state of a policy (accepted when err == nil, otherwise rejected with reason).
func ConditionMarshal ¶
ConditionMarshal marshals the set of conditions as a JSON array, sorted by condition type.
func EnforcedCondition ¶
EnforcedCondition returns a metav1.Condition representing enforcement success (or partial failure) for a policy. If err is non-nil the condition is False with the underlying policy error reason.
func Resolve ¶
func Resolve[T any](ctx context.Context, kuadrantCtx exttypes.KuadrantCtx, policy exttypes.Policy, expression string, subscribe bool) (T, error)
Resolve is a generic helper that evaluates a CEL expression via the KuadrantCtx and converts the result to the requested Go type T.
An error is returned if evaluation fails or the type conversion cannot be satisfied.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder constructs an ExtensionController with a fluent API similar to controller-runtime's builder, adding extension specific concerns (gRPC client, event cache, unix socket path).
func NewBuilder ¶
NewBuilder creates a new Builder for a given controller name and returns it alongside the configured logger.
func (*Builder) Build ¶
func (b *Builder) Build() (*ExtensionController, error)
Build validates the configuration, creates the underlying manager, gRPC client and returns a ready to Start ExtensionController.
func (*Builder) Owns ¶
Owns registers owned object types so that owner references are resolved and reconcile requests enqueued for the owning policy kind.
func (*Builder) Watches ¶
Watches registers additional object types whose events should enqueue the primary object's reconcile requests.
func (*Builder) WithReconciler ¶
func (b *Builder) WithReconciler(fn exttypes.ReconcileFn) *Builder
WithReconciler sets the user reconcile function.
type EventCachingHandler ¶
type EventCachingHandler struct {
// contains filtered or unexported fields
}
EventCachingHandler is a controller-runtime handler that adds the event type to the cache before enqueuing reconcile requests.
func (*EventCachingHandler) Create ¶
func (h *EventCachingHandler) Create(_ context.Context, event ctrlruntimeevent.TypedCreateEvent[client.Object], queue workqueue.TypedRateLimitingInterface[reconcile.Request])
Create implements the handler interface adding a CREATE event.
func (*EventCachingHandler) Delete ¶
func (h *EventCachingHandler) Delete(_ context.Context, event ctrlruntimeevent.TypedDeleteEvent[client.Object], queue workqueue.TypedRateLimitingInterface[reconcile.Request])
Delete implements the handler interface adding a DELETE event.
func (*EventCachingHandler) Generic ¶
func (h *EventCachingHandler) Generic(_ context.Context, event ctrlruntimeevent.TypedGenericEvent[client.Object], queue workqueue.TypedRateLimitingInterface[reconcile.Request])
Generic implements the handler interface adding a GENERIC event.
func (*EventCachingHandler) Update ¶
func (h *EventCachingHandler) Update(_ context.Context, event ctrlruntimeevent.TypedUpdateEvent[client.Object], queue workqueue.TypedRateLimitingInterface[reconcile.Request])
Update implements the handler interface adding an UPDATE event.
type EventTypeCache ¶
type EventTypeCache struct {
// contains filtered or unexported fields
}
EventTypeCache stores a FIFO list of event types per namespaced name so the reconcile loop can retrieve the causal event. Not concurrency heavy, guarded by a RWMutex.
type ExtensionConfig ¶
type ExtensionConfig struct {
Name string
PolicyKind string
ForType client.Object
Reconcile exttypes.ReconcileFn
WatchSources []ctrlruntimesrc.Source
}
ExtensionConfig captures the immutable configuration for a controller instance constructed by the Builder. It determines:
Name: controller name (also used for logging prefix) PolicyKind: the Kind of the primary policy CRD managed ForType: the primary object type reconciled Reconcile: the user provided reconcile function WatchSources: dynamic sources watched (primary, additional and owned)
type ExtensionController ¶
type ExtensionController struct {
*basereconciler.BaseReconciler // TODO(didierofrivia): Next iteration, use policy machinery
// contains filtered or unexported fields
}
ExtensionController is a thin wrapper around controller-runtime's manager and controller that wires gRPC event subscriptions with the reconcile loop and exposes helper methods (Resolve, ReconcileObject, etc.) via the KuadrantCtx interface passed to user code.
func (*ExtensionController) AddDataTo ¶
func (ec *ExtensionController) AddDataTo(ctx context.Context, policy exttypes.Policy, domain exttypes.Domain, binding string, expression string) error
AddDataTo registers a mutator expression that will inject computed data into a policy under the provided domain and binding.
func (*ExtensionController) ClearPolicy ¶
func (ec *ExtensionController) ClearPolicy(ctx context.Context, namespace, name, kind string) error
ClearPolicy removes server side state associated with a policy (mutators, subscriptions) after deletion.
func (*ExtensionController) Manager ¶
func (ec *ExtensionController) Manager() ctrlruntime.Manager
Manager returns the underlying controller-runtime Manager.
func (*ExtensionController) Reconcile ¶
func (ec *ExtensionController) Reconcile(ctx context.Context, request reconcile.Request) (reconcile.Result, error)
Reconcile implements the controller-runtime reconcile loop. It ensures finalizers, dispatches the configured user Reconcile function and performs post‑reconcile cleanup.
func (*ExtensionController) ReconcileObject ¶
func (ec *ExtensionController) ReconcileObject(ctx context.Context, obj client.Object, desired client.Object, mutateFn exttypes.MutateFn) (client.Object, error)
ReconcileObject performs a create/update patch against the API server for a desired object applying the provided mutate function on differences.
func (*ExtensionController) Resolve ¶
func (ec *ExtensionController) Resolve(ctx context.Context, policy exttypes.Policy, expression string, subscribe bool) (ref.Val, error)
Resolve evaluates a CEL expression against the provided policy returning the raw CEL result as a ref.Val. If subscribe is true the extension service will stream future changes (triggering new reconciliations).
func (*ExtensionController) ResolvePolicy ¶
func (ec *ExtensionController) ResolvePolicy(ctx context.Context, policy exttypes.Policy, expression string, subscribe bool) (exttypes.Policy, error)
ResolvePolicy evaluates a CEL expression that must return a Policy protobuf which is then adapted to the generic Policy interface. Used when expressions transform or select policies.
func (*ExtensionController) Start ¶
func (ec *ExtensionController) Start(ctx context.Context) error
Start launches the controller manager and begins processing events.
func (*ExtensionController) Subscribe ¶
func (ec *ExtensionController) Subscribe(ctx context.Context, reconcileChan chan ctrlruntimeevent.GenericEvent)
Subscribe opens a long‑lived gRPC stream for events related to the policy kind and enqueues reconcile requests for received events.