Documentation ¶
Index ¶
- Variables
- func CreateAndSetLogger() logr.Logger
- func Destruct[T any](obj T) (*unstructured.Unstructured, error)
- func FieldsFromObject[T any](obj T, fields []string) map[string]string
- func LoggerFromContext(ctx context.Context) logr.Logger
- func LoggerIntoContext(ctx context.Context, logger logr.Logger) context.Context
- func ObjectAs[T any](obj Object, _ int) T
- func Restructure[T any](obj any) (any, error)
- func ToFieldSelector(s string) fields.Selector
- func ToLabelSelector(s string) labels.Selector
- func TypedEnqueueRequestsMapFunc[T Object](_ context.Context, _ T) []ctrlruntimereconcile.Request
- type CacheStore
- type Controller
- type ControllerOption
- func AllowLoops() ControllerOption
- func ManagedBy(manager ctrlruntime.Manager) ControllerOption
- func WithClient(client *dynamic.DynamicClient) ControllerOption
- func WithLogger(logger logr.Logger) ControllerOption
- func WithName(name string) ControllerOption
- func WithObjectKinds(objectKinds ...schema.GroupKind) ControllerOption
- func WithObjectLinks(objectLinks ...LinkFunc) ControllerOption
- func WithPolicyKinds(policyKinds ...schema.GroupKind) ControllerOption
- func WithReconcile(reconcile ReconcileFunc) ControllerOption
- func WithRunnable(name string, builder RunnableBuilder) ControllerOption
- type ControllerOptions
- type EventType
- type LinkFunc
- type ListFunc
- type Object
- type ObjectsByCreationTimestamp
- type ReconcileFunc
- type ResourceEvent
- type ResourceEventMatcher
- type Runnable
- type RunnableBuilder
- func IncrementalInformer[T Object](obj T, resource schema.GroupVersionResource, namespace string, ...) RunnableBuilder
- func StateReconciler[T Object](obj T, resource schema.GroupVersionResource, namespace string, ...) RunnableBuilder
- func Watch[T Object](obj T, resource schema.GroupVersionResource, namespace string, ...) RunnableBuilder
- type RunnableBuilderOption
- func Builder[T Object](...) RunnableBuilderOption[T]
- func FilterResourcesByField[T Object](selector string) RunnableBuilderOption[T]
- func FilterResourcesByLabel[T Object](selector string) RunnableBuilderOption[T]
- func WithPredicates[T Object](predicates ...ctrlruntimepredicate.TypedPredicate[T]) RunnableBuilderOption[T]
- type RunnableBuilderOptions
- type RuntimeObject
- type Store
- type Subscription
- type WatchFunc
- type Workflow
Constants ¶
This section is empty.
Variables ¶
var ( // core ServicesResource = core.SchemeGroupVersion.WithResource("services") ConfigMapsResource = core.SchemeGroupVersion.WithResource("configmaps") // gateway api GatewayClassesResource = gwapiv1.SchemeGroupVersion.WithResource("gatewayclasses") GatewaysResource = gwapiv1.SchemeGroupVersion.WithResource("gateways") HTTPRoutesResource = gwapiv1.SchemeGroupVersion.WithResource("httproutes") )
API Resources
Functions ¶
func CreateAndSetLogger ¶
CreateAndSetLogger returns a new logger and sets it as the default logger for the controller-runtime and klog packages.
func Destruct ¶
func Destruct[T any](obj T) (*unstructured.Unstructured, error)
func LoggerFromContext ¶
LoggerFromContext returns the logger from the context, or a discard logger if no logger is found.
func LoggerIntoContext ¶
LoggerIntoContext returns a new context with the logger set.
func ToFieldSelector ¶
func ToLabelSelector ¶
func TypedEnqueueRequestsMapFunc ¶
func TypedEnqueueRequestsMapFunc[T Object](_ context.Context, _ T) []ctrlruntimereconcile.Request
Types ¶
type CacheStore ¶ added in v0.3.0
func (*CacheStore) Add ¶ added in v0.3.0
func (c *CacheStore) Add(storeId string, obj Object)
func (*CacheStore) Delete ¶ added in v0.3.0
func (c *CacheStore) Delete(storeId string, obj Object)
func (*CacheStore) List ¶ added in v0.3.0
func (c *CacheStore) List(storeId string) Store
func (*CacheStore) Replace ¶ added in v0.3.0
func (c *CacheStore) Replace(storeId string, store Store)
type Controller ¶
func NewController ¶
func NewController(f ...ControllerOption) *Controller
func (*Controller) Reconcile ¶
func (c *Controller) Reconcile(ctx context.Context, _ ctrlruntimereconcile.Request) (ctrlruntimereconcile.Result, error)
type ControllerOption ¶
type ControllerOption func(*ControllerOptions)
func AllowLoops ¶
func AllowLoops() ControllerOption
func ManagedBy ¶
func ManagedBy(manager ctrlruntime.Manager) ControllerOption
func WithClient ¶
func WithClient(client *dynamic.DynamicClient) ControllerOption
func WithLogger ¶
func WithLogger(logger logr.Logger) ControllerOption
func WithName ¶
func WithName(name string) ControllerOption
func WithObjectKinds ¶
func WithObjectKinds(objectKinds ...schema.GroupKind) ControllerOption
func WithObjectLinks ¶
func WithObjectLinks(objectLinks ...LinkFunc) ControllerOption
func WithPolicyKinds ¶
func WithPolicyKinds(policyKinds ...schema.GroupKind) ControllerOption
func WithReconcile ¶
func WithReconcile(reconcile ReconcileFunc) ControllerOption
func WithRunnable ¶
func WithRunnable(name string, builder RunnableBuilder) ControllerOption
type ControllerOptions ¶
type ControllerOptions struct {
// contains filtered or unexported fields
}
type ObjectsByCreationTimestamp ¶ added in v0.4.0
type ObjectsByCreationTimestamp []Object
ObjectsByCreationTimestamp is a slice of RuntimeObject that can be sorted by creation timestamp RuntimeObjects with the oldest creation timestamp will appear first; if two objects have the same creation timestamp, the object appearing first in alphabetical order by namespace/name will appear first.
func (ObjectsByCreationTimestamp) Len ¶ added in v0.4.0
func (a ObjectsByCreationTimestamp) Len() int
func (ObjectsByCreationTimestamp) Less ¶ added in v0.4.0
func (a ObjectsByCreationTimestamp) Less(i, j int) bool
func (ObjectsByCreationTimestamp) Swap ¶ added in v0.4.0
func (a ObjectsByCreationTimestamp) Swap(i, j int)
type ReconcileFunc ¶
type ReconcileFunc func(context.Context, []ResourceEvent, *machinery.Topology, error, *sync.Map) error
ReconcileFunc is a function that reconciles a particular state of the world. It receives a list of recent events, an immutable copy of the topology as known by the caller after the events, an optional error detected before the reconciliation, and a thread-safe map to store transient state across chained calls to multiple ReconcileFuncs. If a ReconcileFunc returns an error, a chained sequence of ReconcileFuncs must be interrupted.
type ResourceEvent ¶
type ResourceEventMatcher ¶
type RunnableBuilder ¶
type RunnableBuilder func(controller *Controller) Runnable
func IncrementalInformer ¶
func IncrementalInformer[T Object](obj T, resource schema.GroupVersionResource, namespace string, options ...RunnableBuilderOption[T]) RunnableBuilder
func StateReconciler ¶
func StateReconciler[T Object](obj T, resource schema.GroupVersionResource, namespace string, options ...RunnableBuilderOption[T]) RunnableBuilder
func Watch ¶
func Watch[T Object](obj T, resource schema.GroupVersionResource, namespace string, options ...RunnableBuilderOption[T]) RunnableBuilder
type RunnableBuilderOption ¶
type RunnableBuilderOption[T Object] func(*RunnableBuilderOptions[T])
func Builder ¶
func Builder[T Object](builder func(obj T, resource schema.GroupVersionResource, namespace string, options ...RunnableBuilderOption[T]) RunnableBuilder) RunnableBuilderOption[T]
func FilterResourcesByField ¶
func FilterResourcesByField[T Object](selector string) RunnableBuilderOption[T]
func FilterResourcesByLabel ¶
func FilterResourcesByLabel[T Object](selector string) RunnableBuilderOption[T]
func WithPredicates ¶ added in v0.3.0
func WithPredicates[T Object](predicates ...ctrlruntimepredicate.TypedPredicate[T]) RunnableBuilderOption[T]
type RunnableBuilderOptions ¶
type RunnableBuilderOptions[T Object] struct { LabelSelector string FieldSelector string Predicates []ctrlruntimepredicate.TypedPredicate[T] Builder func(obj T, resource schema.GroupVersionResource, namespace string, options ...RunnableBuilderOption[T]) RunnableBuilder }
type RuntimeObject ¶
type RuntimeObject struct {
Object
}
RuntimeObject is a wrapper around a Kubernetes runtime object, that also implements the machinery.Object interface Use it for wrapping runtime objects that do not natively implement machinery.Object, so such object can be added to a machinery.Topology
func (*RuntimeObject) GetLocator ¶
func (o *RuntimeObject) GetLocator() string
func (*RuntimeObject) GetName ¶
func (o *RuntimeObject) GetName() string
func (*RuntimeObject) GetNamespace ¶
func (o *RuntimeObject) GetNamespace() string
func (*RuntimeObject) GroupVersionKind ¶
func (o *RuntimeObject) GroupVersionKind() schema.GroupVersionKind
func (*RuntimeObject) SetGroupVersionKind ¶
func (o *RuntimeObject) SetGroupVersionKind(schema.GroupVersionKind)
type Subscription ¶
type Subscription struct { ReconcileFunc ReconcileFunc Events []ResourceEventMatcher }
Subscription runs a reconciliation function when the list of events has at least one event in common with the list of event matchers. The list of events then propagated to the reconciliation function is filtered to the ones the match only.
type WatchFunc ¶
type WatchFunc func(ctrlruntime.Manager) ctrlruntimesrc.Source
type Workflow ¶
type Workflow struct { Precondition ReconcileFunc Tasks []ReconcileFunc Postcondition ReconcileFunc ErrorHandler ReconcileFunc }
Workflow runs an optional precondition reconciliation function, then dispatches the reconciliation event to a list of concurrent reconciliation tasks, and runs an optional postcondition reconciliation function.
If any of the reconciliation functions returns an error, the error is handled by an optional error handler. The error passed to the error handler func is conflated with any occasional error carried over into the call to the workflow in the first place. It is up to the error handler to decide how to handle the error and whether to supress it or raise it again. Supressed errors cause the workflow to continue running, while raised errors interrupt the workflow. If the error handler is nil, the error is raised.