Documentation
¶
Index ¶
- Constants
- Variables
- func Chain(children ...handler.Builder) handler.Builder
- func HashEqual(a, b string) bool
- func HashObject(obj interface{}) (string, error)
- func IsPaused(object metav1.Object, pausedLabelKey string) bool
- func NewPausedCondition(pausedLabelKey string) metav1.Condition
- func NewSelfPausedCondition(pausedLabelKey string) metav1.Condition
- func Parallel(children ...handler.Builder) handler.Builder
- func SecureHashEqual(a, b string) bool
- func SecureHashObject(obj interface{}) (string, error)
- func ShouldRetry(err error) (bool, time.Duration)
- type Annotator
- type BuilderComposer
- type BuilderMiddleware
- type Component
- type ComponentContextHandler
- type ContextDefaultingKey
- type ContextHandle
- type ContextHandleDefaultingKey
- func (k *ContextHandleDefaultingKey[V]) HandleBuilder(id handler.Key) handler.Builder
- func (k *ContextHandleDefaultingKey[V]) MustValue(ctx context.Context) V
- func (k *ContextHandleDefaultingKey[V]) Value(ctx context.Context) V
- func (k *ContextHandleDefaultingKey[V]) WithHandle(ctx context.Context) context.Context
- func (k *ContextHandleDefaultingKey[V]) WithValue(ctx context.Context, val V) context.Context
- type ContextKey
- type ControlAll
- type ControlDone
- type ControlDoneRequeue
- type ControlDoneRequeueAfter
- type ControlDoneRequeueErr
- type ControlOpt
- type ControlRequeue
- type ControlRequeueAPIErr
- type ControlRequeueAfter
- type ControlRequeueErr
- type EnsureComponentByHash
- type FileInformer
- type FileInformerFactory
- type FileSharedIndexInformer
- func (f *FileSharedIndexInformer) AddEventHandler(handler cache.ResourceEventHandler)
- func (f *FileSharedIndexInformer) AddEventHandlerWithResyncPeriod(handler cache.ResourceEventHandler, resyncPeriod time.Duration)
- func (f *FileSharedIndexInformer) AddIndexers(indexers cache.Indexers) error
- func (f *FileSharedIndexInformer) GetController() cache.Controller
- func (f *FileSharedIndexInformer) GetIndexer() cache.Indexer
- func (f *FileSharedIndexInformer) GetStore() cache.Store
- func (f *FileSharedIndexInformer) HasSynced() bool
- func (f *FileSharedIndexInformer) LastSyncResourceVersion() string
- func (f *FileSharedIndexInformer) Run(stopCh <-chan struct{})
- func (f *FileSharedIndexInformer) SetWatchErrorHandler(handler cache.WatchErrorHandler) error
- type HandlerControls
- type HandlerMiddleware
- type HasStatusConditions
- type HashEqualFunc
- type HashableComponent
- type Middleware
- type ObjectHashFunc
- type ObjectHasher
- type PauseHandler
- type SelfPauseHandler
- type SettableContext
Constants ¶
const ConditionTypePaused = "Paused"
Variables ¶
var FileGroupVersion = schema.GroupVersion{
Group: "//LocalFile",
Version: "v1",
}
Functions ¶
func HashObject ¶
func NewPausedCondition ¶
func NewSelfPausedCondition ¶
func Parallel ¶
Parallel creates a new handler.Builder that runs a set of handler.Builder in parallel
func SecureHashEqual ¶
func SecureHashObject ¶
Types ¶
type BuilderComposer ¶
BuilderComposer is a function that composes sets of handler.Builder into one handler.Builder, see `Chain` and `Parallel`.
func ChainWithMiddleware ¶
func ChainWithMiddleware(middleware ...Middleware) BuilderComposer
func ParallelWithMiddleware ¶
func ParallelWithMiddleware(middleware ...Middleware) BuilderComposer
func WithMiddleware ¶
func WithMiddleware(composer BuilderComposer, middleware ...Middleware) BuilderComposer
WithMiddleware returns a new BuilderComposer with all middleware applied
type BuilderMiddleware ¶
BuilderMiddleware returns a new (wrapped) Builder given a Builder
func MakeBuilderMiddleware ¶
func MakeBuilderMiddleware(w HandlerMiddleware) BuilderMiddleware
MakeBuilderMiddleware generates the corresponding BuilderMiddleware from a HandlerMiddleware.
type Component ¶
Component represents an object in the cluster that is "related" to another i.e. a pod would be a component of a deployment (though direct ownership is not required).
func NewComponent ¶
func NewComponent[K metav1.Object](informers map[schema.GroupVersionResource]dynamicinformer.DynamicSharedInformerFactory, gvr schema.GroupVersionResource, indexName string, selector labels.Selector) *Component[K]
NewComponent creates a component from an index name, a gvr, a selector, and a set of informers.
type ComponentContextHandler ¶
type ComponentContextHandler[K metav1.Object] struct { HandlerControls // contains filtered or unexported fields }
ComponentContextHandler fills the value for a ContextKey with the result of fetching a component.
func NewComponentContextHandler ¶
func NewComponentContextHandler[K metav1.Object](ctrls HandlerControls, contextKey SettableContext[[]K], component *Component[K], owner fmt.Stringer, next handler.ContextHandler) *ComponentContextHandler[K]
func (*ComponentContextHandler[K]) Handle ¶
func (h *ComponentContextHandler[K]) Handle(ctx context.Context)
type ContextDefaultingKey ¶
type ContextDefaultingKey[V comparable] struct { // contains filtered or unexported fields }
ContextDefaultingKey is a type that is used as a key in a context.Context for a specific type of value, but returns the default value for V if unset.
func NewContextDefaultingKey ¶
func NewContextDefaultingKey[V comparable](defaultValue V) *ContextDefaultingKey[V]
func (*ContextDefaultingKey[V]) MustValue ¶
func (k *ContextDefaultingKey[V]) MustValue(ctx context.Context) V
func (*ContextDefaultingKey[V]) Value ¶
func (k *ContextDefaultingKey[V]) Value(ctx context.Context) V
type ContextHandle ¶
type ContextHandle[V any] struct { // contains filtered or unexported fields }
type ContextHandleDefaultingKey ¶
type ContextHandleDefaultingKey[V any] struct { // contains filtered or unexported fields }
ContextHandleDefaultingKey is a type that is used as a key in a context.Context that points to a handle containing the desired value. This allows a handler higher up in the chain to carve out a spot to be filled in by other handlers. It can also be used to hold non-comparable objects by wrapping them with a pointer.
func NewContextHandleDefaultingKey ¶
func NewContextHandleDefaultingKey[V any](defaultValue V) *ContextHandleDefaultingKey[V]
func (*ContextHandleDefaultingKey[V]) HandleBuilder ¶
func (k *ContextHandleDefaultingKey[V]) HandleBuilder(id handler.Key) handler.Builder
HandleBuilder returns a HandleBuilder that calls WithHandle before calling the next handler in the chain.
func (*ContextHandleDefaultingKey[V]) MustValue ¶
func (k *ContextHandleDefaultingKey[V]) MustValue(ctx context.Context) V
func (*ContextHandleDefaultingKey[V]) Value ¶
func (k *ContextHandleDefaultingKey[V]) Value(ctx context.Context) V
func (*ContextHandleDefaultingKey[V]) WithHandle ¶
func (k *ContextHandleDefaultingKey[V]) WithHandle(ctx context.Context) context.Context
type ContextKey ¶
type ContextKey[V comparable] struct{}
ContextKey is a type that is used as a key in a context.Context for a specific type of value V. It mimics the context.Context interface
func NewContextKey ¶
func NewContextKey[V comparable]() *ContextKey[V]
func (*ContextKey[V]) MustValue ¶
func (k *ContextKey[V]) MustValue(ctx context.Context) V
type ControlAll ¶
type ControlAll interface {
ControlDone
ControlRequeue
ControlRequeueAfter
ControlRequeueErr
ControlRequeueAPIErr
}
type ControlDone ¶
type ControlDone interface {
Done()
}
type ControlDoneRequeue ¶
type ControlDoneRequeue interface {
ControlDone
ControlRequeue
}
type ControlDoneRequeueAfter ¶
type ControlDoneRequeueAfter interface {
ControlDone
ControlRequeueAfter
}
type ControlDoneRequeueErr ¶
type ControlDoneRequeueErr interface {
ControlDone
ControlRequeueErr
}
type ControlOpt ¶
type ControlOpt func(*HandlerControls)
func WithDone ¶
func WithDone(doneFunc func()) ControlOpt
func WithRequeue ¶
func WithRequeue(requeueFunc func()) ControlOpt
func WithRequeueAfter ¶
func WithRequeueAfter(requeueAfterFunc func(duration time.Duration)) ControlOpt
func WithRequeueImmediate ¶
func WithRequeueImmediate(requeueFunc func(duration time.Duration)) ControlOpt
type ControlRequeue ¶
type ControlRequeue interface {
Requeue()
}
type ControlRequeueAPIErr ¶
type ControlRequeueAPIErr interface {
ControlDone
ControlRequeue
ControlRequeueAfter
RequeueAPIErr(err error)
}
type ControlRequeueAfter ¶
type ControlRequeueErr ¶
type ControlRequeueErr interface {
ControlRequeue
RequeueErr(err error)
}
type EnsureComponentByHash ¶
type EnsureComponentByHash[K metav1.Object, A Annotator[A]] struct { ControlRequeueErr *HashableComponent[K] // contains filtered or unexported fields }
func NewEnsureComponentByHash ¶
func NewEnsureComponentByHash[K metav1.Object, A Annotator[A]]( component *HashableComponent[K], owner types.NamespacedName, ctrls ControlRequeueErr, applyObj func(ctx context.Context, apply A) (K, error), deleteObject func(ctx context.Context, name string) error, newObj func(ctx context.Context) A, ) *EnsureComponentByHash[K, A]
func (*EnsureComponentByHash[K, A]) Handle ¶
func (e *EnsureComponentByHash[K, A]) Handle(ctx context.Context)
type FileInformer ¶
type FileInformer struct {
// contains filtered or unexported fields
}
func NewFileInformer ¶
func NewFileInformer(watcher *fsnotify.Watcher, gvr schema.GroupVersionResource) (*FileInformer, error)
func (*FileInformer) Informer ¶
func (f *FileInformer) Informer() cache.SharedIndexInformer
func (*FileInformer) Lister ¶
func (f *FileInformer) Lister() cache.GenericLister
type FileInformerFactory ¶
func NewFileInformerFactory ¶
func NewFileInformerFactory() (*FileInformerFactory, error)
func (*FileInformerFactory) ForResource ¶
func (f *FileInformerFactory) ForResource(gvr schema.GroupVersionResource) informers.GenericInformer
func (*FileInformerFactory) Start ¶
func (f *FileInformerFactory) Start(stopCh <-chan struct{})
func (*FileInformerFactory) WaitForCacheSync ¶
func (f *FileInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[schema.GroupVersionResource]bool
type FileSharedIndexInformer ¶
type FileSharedIndexInformer struct {
// contains filtered or unexported fields
}
func NewFileSharedIndexInformer ¶
func NewFileSharedIndexInformer(fileName string, watcher *fsnotify.Watcher, defaultEventHandlerResyncPeriod time.Duration) *FileSharedIndexInformer
NewFileSharedIndexInformer creates a new informer watching the file Note that currently all event handlers share the default resync period.
func (*FileSharedIndexInformer) AddEventHandler ¶
func (f *FileSharedIndexInformer) AddEventHandler(handler cache.ResourceEventHandler)
func (*FileSharedIndexInformer) AddEventHandlerWithResyncPeriod ¶
func (f *FileSharedIndexInformer) AddEventHandlerWithResyncPeriod(handler cache.ResourceEventHandler, resyncPeriod time.Duration)
func (*FileSharedIndexInformer) AddIndexers ¶
func (f *FileSharedIndexInformer) AddIndexers(indexers cache.Indexers) error
func (*FileSharedIndexInformer) GetController ¶
func (f *FileSharedIndexInformer) GetController() cache.Controller
func (*FileSharedIndexInformer) GetIndexer ¶
func (f *FileSharedIndexInformer) GetIndexer() cache.Indexer
func (*FileSharedIndexInformer) GetStore ¶
func (f *FileSharedIndexInformer) GetStore() cache.Store
func (*FileSharedIndexInformer) HasSynced ¶
func (f *FileSharedIndexInformer) HasSynced() bool
func (*FileSharedIndexInformer) LastSyncResourceVersion ¶
func (f *FileSharedIndexInformer) LastSyncResourceVersion() string
func (*FileSharedIndexInformer) Run ¶
func (f *FileSharedIndexInformer) Run(stopCh <-chan struct{})
func (*FileSharedIndexInformer) SetWatchErrorHandler ¶
func (f *FileSharedIndexInformer) SetWatchErrorHandler(handler cache.WatchErrorHandler) error
type HandlerControls ¶
type HandlerControls struct {
// contains filtered or unexported fields
}
func HandlerControlsWith ¶
func HandlerControlsWith(opts ...ControlOpt) HandlerControls
func (HandlerControls) Done ¶
func (c HandlerControls) Done()
func (HandlerControls) Requeue ¶
func (c HandlerControls) Requeue()
func (HandlerControls) RequeueAPIErr ¶
func (c HandlerControls) RequeueAPIErr(err error)
func (HandlerControls) RequeueAfter ¶
func (c HandlerControls) RequeueAfter(duration time.Duration)
func (HandlerControls) RequeueErr ¶
func (c HandlerControls) RequeueErr(err error)
type HandlerMiddleware ¶
HandlerMiddleware returns a new (wrapped) Handler given a Handler
type HasStatusConditions ¶
type HasStatusConditions interface {
comparable
metav1.Object
FindStatusCondition(conditionType string) *metav1.Condition
SetStatusCondition(metav1.Condition)
GetStatusConditions() []metav1.Condition
}
HasStatusConditions is used for pausing
type HashEqualFunc ¶
type HashableComponent ¶
type HashableComponent[K metav1.Object] struct { Component[K] ObjectHasher HashAnnotationKey string }
HashableComponent is a Component with an annotation that stores a hash of the previous configuration the controller wrote
func NewHashableComponent ¶
func NewHashableComponent[K metav1.Object](component Component[K], hasher ObjectHasher, key string) *HashableComponent[K]
type Middleware ¶
type Middleware func(BuilderComposer) BuilderComposer
Middleware operates on BuilderComposer (to wrap all underlying builders)
func MakeMiddleware ¶
func MakeMiddleware(w HandlerMiddleware) Middleware
MakeMiddleware generates the corresponding Middleware for HandlerMiddleware
type ObjectHashFunc ¶
type ObjectHasher ¶
func NewObjectHash ¶
func NewObjectHash() ObjectHasher
func NewSecureObjectHash ¶
func NewSecureObjectHash() ObjectHasher
type PauseHandler ¶
type PauseHandler[K HasStatusConditions] struct { ControlDoneRequeueErr PausedLabelKey string Object K PatchStatus func(ctx context.Context, patch K) error Next handler.ContextHandler }
func NewPauseHandler ¶
func NewPauseHandler[K HasStatusConditions](ctrls ControlDoneRequeueErr, pausedLabelKey string, object K, patchStatus func(ctx context.Context, patch K) error, next handler.ContextHandler, ) *PauseHandler[K]
func (*PauseHandler[K]) Handle ¶
func (p *PauseHandler[K]) Handle(ctx context.Context)
type SelfPauseHandler ¶
type SelfPauseHandler[K HasStatusConditions] struct { HandlerControls CtxKey *ContextDefaultingKey[K] PausedLabelKey string OwnerUID types.UID Patch func(ctx context.Context, patch K) error PatchStatus func(ctx context.Context, patch K) error }
SelfPauseHandler is used when the controller pauses itself. This is only used when the controller has no good way to tell when the bad state has been resolved (i.e. an external resource is behaving poorly).
func NewSelfPauseHandler ¶
func NewSelfPauseHandler[K HasStatusConditions](ctrls HandlerControls, pausedLabelKey string, contextKey *ContextDefaultingKey[K], ownerUID types.UID, patch, patchStatus func(ctx context.Context, patch K) error, ) *SelfPauseHandler[K]
func (*SelfPauseHandler[K]) Handle ¶
func (p *SelfPauseHandler[K]) Handle(ctx context.Context)