controller

package
v1.15.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 22 Imported by: 1,069

Documentation

Overview

Package controller provides utilties for working with controllers.

Index

Constants

This section is empty.

Variables

View Source
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

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

type ESSOptions struct {
	TLSConfig     *tls.Config
	TLSSecretName *string
}

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

func (e *Engine) Err(name string) error

Err returns any error encountered by the named controller. The returned error is always nil if the named controller is running.

func (*Engine) IsRunning

func (e *Engine) IsRunning(name string) bool

IsRunning indicates whether the named controller is running - i.e. whether it has been started and does not appear to have crashed.

func (*Engine) Start

func (e *Engine) Start(name string, o controller.Options, w ...Watch) error

Start the named controller. Each controller is started with its own cache whose lifecycle is coupled to the controller. The controller is started with the supplied options, and configured with the supplied watches. Start does not block.

func (*Engine) Stop

func (e *Engine) Stop(name string)

Stop the named controller.

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

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

func (c *GVKRoutedCache) RemoveInformer(ctx context.Context, obj client.Object) error

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

type NamedController interface {
	Start(ctx context.Context) error
	GetCache() cache.Cache
}

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

type NewCacheFn func(cfg *rest.Config, o cache.Options) (cache.Cache, error)

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

func TriggeredBy(source source.Source, h handler.EventHandler, p ...predicate.Predicate) Watch

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL