Documentation ¶
Overview ¶
Package controller provides utilties for working with controllers.
Index ¶
- Variables
- func WithGVKRoutedCache(c *GVKRoutedCache, mgr controllerruntime.Manager) controllerruntime.Manager
- type ESSOptions
- type Engine
- type EngineOption
- type GVKRoutedCache
- func (c *GVKRoutedCache) AddDelegate(gvk schema.GroupVersionKind, delegate cache.Cache)
- func (c *GVKRoutedCache) Get(ctx context.Context, key client.ObjectKey, obj client.Object, ...) error
- func (c *GVKRoutedCache) GetInformer(ctx context.Context, obj client.Object, opts ...cache.InformerGetOption) (cache.Informer, error)
- func (c *GVKRoutedCache) GetInformerForKind(ctx context.Context, gvk schema.GroupVersionKind, ...) (cache.Informer, error)
- func (c *GVKRoutedCache) IndexField(ctx context.Context, obj client.Object, field string, ...) error
- func (c *GVKRoutedCache) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error
- func (c *GVKRoutedCache) RemoveDelegate(gvk schema.GroupVersionKind)
- func (c *GVKRoutedCache) RemoveInformer(ctx context.Context, obj client.Object) error
- func (c *GVKRoutedCache) Start(_ context.Context) error
- func (c *GVKRoutedCache) WaitForCacheSync(ctx context.Context) bool
- type NamedController
- type NewCacheFn
- type NewControllerFn
- type Options
- type Watch
Constants ¶
This section is empty.
Variables ¶
var ( DefaultNewCacheFn NewCacheFn = cache.New DefaultNewControllerFn NewControllerFn = controller.NewUnmanaged )
The default new cache and new controller functions.
Functions ¶
func WithGVKRoutedCache ¶ added in v1.14.0
func WithGVKRoutedCache(c *GVKRoutedCache, mgr controllerruntime.Manager) controllerruntime.Manager
WithGVKRoutedCache returns a manager backed by a GVKRoutedCache. The client returned by the manager will route read requests to cached GVKs.
Types ¶
type ESSOptions ¶ added in v0.20.0
ESSOptions for External Secret Stores.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
An Engine manages the lifecycles of controller-runtime controllers (and their caches). The lifecycles of the controllers are not coupled to lifecycle of the engine, nor to the lifecycle of the controller manager it uses.
func NewEngine ¶
func NewEngine(mgr manager.Manager, o ...EngineOption) *Engine
NewEngine produces a new Engine.
func (*Engine) Create ¶ added in v1.14.0
func (e *Engine) Create(name string, o controller.Options, w ...Watch) (NamedController, error)
Create the named controller. Each controller gets its own cache whose lifecycle is coupled to the controller. The controller is created with the supplied options, and configured with the supplied watches. It is not started yet.
func (*Engine) Err ¶
Err returns any error encountered by the named controller. The returned error is always nil if the named controller is running.
func (*Engine) IsRunning ¶
IsRunning indicates whether the named controller is running - i.e. whether it has been started and does not appear to have crashed.
type EngineOption ¶
type EngineOption func(*Engine)
An EngineOption configures an Engine.
func WithNewCacheFn ¶
func WithNewCacheFn(fn NewCacheFn) EngineOption
WithNewCacheFn may be used to configure a different cache implementation. DefaultNewCacheFn is used by default.
func WithNewControllerFn ¶
func WithNewControllerFn(fn NewControllerFn) EngineOption
WithNewControllerFn may be used to configure a different controller implementation. DefaultNewControllerFn is used by default.
type GVKRoutedCache ¶ added in v1.14.0
type GVKRoutedCache struct {
// contains filtered or unexported fields
}
GVKRoutedCache is a cache that routes requests by GVK to other caches.
func NewGVKRoutedCache ¶ added in v1.14.0
func NewGVKRoutedCache(scheme *runtime.Scheme, fallback cache.Cache) *GVKRoutedCache
NewGVKRoutedCache returns a new routed cache.
func (*GVKRoutedCache) AddDelegate ¶ added in v1.14.0
func (c *GVKRoutedCache) AddDelegate(gvk schema.GroupVersionKind, delegate cache.Cache)
AddDelegate adds a delegated cache for a given GVK.
func (*GVKRoutedCache) Get ¶ added in v1.14.0
func (c *GVKRoutedCache) Get(ctx context.Context, key client.ObjectKey, obj client.Object, opts ...client.GetOption) error
Get retrieves an object for a given ObjectKey backed by a cache.
func (*GVKRoutedCache) GetInformer ¶ added in v1.14.0
func (c *GVKRoutedCache) GetInformer(ctx context.Context, obj client.Object, opts ...cache.InformerGetOption) (cache.Informer, error)
GetInformer returns an informer for the given object.
func (*GVKRoutedCache) GetInformerForKind ¶ added in v1.14.0
func (c *GVKRoutedCache) GetInformerForKind(ctx context.Context, gvk schema.GroupVersionKind, opts ...cache.InformerGetOption) (cache.Informer, error)
GetInformerForKind returns an informer for the given GVK.
func (*GVKRoutedCache) IndexField ¶ added in v1.14.0
func (c *GVKRoutedCache) IndexField(ctx context.Context, obj client.Object, field string, extractValue client.IndexerFunc) error
IndexField adds an index with the given field name on the given object type by using the given function to extract the value for that field.
func (*GVKRoutedCache) List ¶ added in v1.14.0
func (c *GVKRoutedCache) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error
List lists objects for a given ObjectList backed by a cache.
func (*GVKRoutedCache) RemoveDelegate ¶ added in v1.14.0
func (c *GVKRoutedCache) RemoveDelegate(gvk schema.GroupVersionKind)
RemoveDelegate removes a delegated cache for a given GVK.
func (*GVKRoutedCache) RemoveInformer ¶ added in v1.15.0
RemoveInformer removes an informer entry and stops it if it was running.
func (*GVKRoutedCache) Start ¶ added in v1.14.0
func (c *GVKRoutedCache) Start(_ context.Context) error
Start for a GVKRoutedCache is a no-op. Start must be called for each delegate.
func (*GVKRoutedCache) WaitForCacheSync ¶ added in v1.14.0
func (c *GVKRoutedCache) WaitForCacheSync(ctx context.Context) bool
WaitForCacheSync for a GVKRoutedCache waits for all delegates and the fallback to sync, and returns false if any of them fails to sync.
type NamedController ¶ added in v1.14.0
NamedController is a controller that's not yet started. It gives access to the underlying cache, which may be used e.g. to add indexes.
type NewCacheFn ¶
A NewCacheFn creates a new controller-runtime cache.
type NewControllerFn ¶
type NewControllerFn func(name string, m manager.Manager, o controller.Options) (controller.Controller, error)
A NewControllerFn creates a new controller-runtime controller.
type Options ¶ added in v0.16.0
type Options struct { // The Logger controllers should use. Logger logging.Logger // The GlobalRateLimiter used by this controller manager. The rate of // reconciles across all controllers will be subject to this limit. GlobalRateLimiter workqueue.RateLimiter // PollInterval at which each controller should speculatively poll to // determine whether it has work to do. PollInterval time.Duration // MaxConcurrentReconciles for each controller. MaxConcurrentReconciles int // Features that should be enabled. Features *feature.Flags // ESSOptions for External Secret Stores. ESSOptions *ESSOptions }
Options frequently used by most Crossplane controllers.
func DefaultOptions ¶ added in v0.16.0
func DefaultOptions() Options
DefaultOptions returns a functional set of options with conservative defaults.
func (Options) ForControllerRuntime ¶ added in v0.16.0
func (o Options) ForControllerRuntime() controller.Options
ForControllerRuntime extracts options for controller-runtime.
type Watch ¶
type Watch struct {
// contains filtered or unexported fields
}
Watch an object.
func For ¶
For returns a Watch for the supplied kind of object. Events will be handled by the supplied EventHandler, and may be filtered by the supplied predicates.
func TriggeredBy ¶ added in v1.14.0
TriggeredBy returns a custom watch for secondary resources triggering the controller. source.Kind can be used to create a source for a secondary cache. Events will be handled by the supplied EventHandler, and may be filtered by the supplied predicates.