duck

package
v0.29.13 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: Apache-2.0 Imports: 20 Imported by: 4

README

Duck Typing

This package implements a kubebuilder controller-runtime compatible Client, Lister and Controller. To learn about Duck Typing, read Knative Duck Typing.

Differences with Knative Implementation

  • Uses kubebuilder controller-runtime
  • Use Typed clients and Informer/Lister to watch instead of the dynamic client in kantive implementation. This allows users of this package to also watch the underlying types directly if needed using the same lister/watcher.
  • Instead of using JSON to marshal api types to duck types, we depend on the Duckify converter method. This allows us to take advantage of duck typing even when the JSON format is not compatible.

Examples

api

controller

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientBuilder

type ClientBuilder struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient() *ClientBuilder

func (*ClientBuilder) Build

func (b *ClientBuilder) Build(c client.Client) (client.Client, error)

func (*ClientBuilder) ForDuckType

func (b *ClientBuilder) ForDuckType(obj Object) *ClientBuilder

func (*ClientBuilder) WithUnderlyingType

func (b *ClientBuilder) WithUnderlyingType(obj client.Object) *ClientBuilder

type ControllerBuilder

type ControllerBuilder struct {
	// contains filtered or unexported fields
}

ControllerBuilder builds a Controller.

func ControllerManagedBy

func ControllerManagedBy(m manager.Manager) *ControllerBuilder

ControllerManagedBy returns a new controller builder that will be started by the provided Manager.

func (*ControllerBuilder) Complete

func (blder *ControllerBuilder) Complete(rb ReconcilerBuilder) error

Complete builds the Application Controller.

func (*ControllerBuilder) For

func (blder *ControllerBuilder) For(object Object, opts ...builder.ForOption) *ControllerBuilder

For defines the type of Object being *reconciled*, and configures the ControllerManagedBy to respond to create / delete / update events by *reconciling the object*. This is the equivalent of calling Watches(&source.Kind{Type: apiType}, &handler.EnqueueRequestForObject{}).

func (*ControllerBuilder) Named

func (blder *ControllerBuilder) Named(name string) *ControllerBuilder

Named sets the name of the controller to the given name. The name shows up in metrics, among other things, and thus should be a prometheus compatible name (underscores and alphanumeric characters only).

By default, controllers are named using the lowercase version of their kind.

func (*ControllerBuilder) Owns

func (blder *ControllerBuilder) Owns(object client.Object, opts ...builder.OwnsOption) *ControllerBuilder

Owns defines types of Objects being *generated* by the ControllerManagedBy, and configures the ControllerManagedBy to respond to create / delete / update events by *reconciling the owner object*. This is the equivalent of calling Watches(&source.Kind{Type: <ForType-forInput>}, &handler.EnqueueRequestForOwner{OwnerType: apiType, IsController: true}).

func (*ControllerBuilder) Watches

func (blder *ControllerBuilder) Watches(src source.Source, eventhandler handler.EventHandler, opts ...builder.WatchesOption) *ControllerBuilder

Watches exposes the lower-level ControllerManagedBy Watches functions through the builder. Consider using Owns or For instead of Watches directly. Specified predicates are registered only for given source.

func (*ControllerBuilder) WithEventFilter

func (blder *ControllerBuilder) WithEventFilter(p predicate.Predicate) *ControllerBuilder

WithEventFilter sets the event filters, to filter which create/update/delete/generic events eventually trigger reconciliations. For example, filtering on whether the resource version has changed. Given predicate is added for all watched objects. Defaults to the empty list.

func (*ControllerBuilder) WithLogConstructor

func (blder *ControllerBuilder) WithLogConstructor(logConstructor func(*reconcile.Request) logr.Logger) *ControllerBuilder

WithLogConstructor overrides the controller options's LogConstructor.

func (*ControllerBuilder) WithOptions

func (blder *ControllerBuilder) WithOptions(options controller.Options) *ControllerBuilder

WithOptions overrides the controller options use in doController. Defaults to empty.

func (*ControllerBuilder) WithUnderlyingTypes

func (blder *ControllerBuilder) WithUnderlyingTypes(rawObj client.Object, rest ...client.Object) *ControllerBuilder

type ForInput

type ForInput struct {
	// contains filtered or unexported fields
}

ForInput represents the information set by For method.

type Lister

type Lister interface {
	// List retrieves list of objects for a given namespace and list options. On a
	// successful call, Items field in the list will be populated with the
	// result returned from the server.
	List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error

	Client(obj client.Object) (client.Client, error)
}

Lister knows how to list Kubernetes objects.

type ListerBuilder

type ListerBuilder struct {
	// contains filtered or unexported fields
}

func NewLister

func NewLister() *ListerBuilder

func (*ListerBuilder) Build

func (b *ListerBuilder) Build(c client.Client) (Lister, error)

func (*ListerBuilder) ForDuckType

func (b *ListerBuilder) ForDuckType(obj Object) *ListerBuilder

func (*ListerBuilder) WithUnderlyingTypes added in v0.25.13

func (b *ListerBuilder) WithUnderlyingTypes(objs client.Object, rest ...client.Object) *ListerBuilder

type ListerImpl

type ListerImpl struct {
	// contains filtered or unexported fields
}

func (*ListerImpl) Client

func (d *ListerImpl) Client(obj client.Object) (client.Client, error)

func (*ListerImpl) List

func (d *ListerImpl) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error

func (*ListerImpl) RESTMapper

func (d *ListerImpl) RESTMapper() apimeta.RESTMapper

RESTMapper returns the rest this client is using.

func (*ListerImpl) Scheme

func (d *ListerImpl) Scheme() *runtime.Scheme

Scheme returns the scheme this client is using.

type Object

type Object interface {
	metav1.Object
	runtime.Object
	Duckify(srcRaw runtime.Object) error
}

type OwnsInput

type OwnsInput struct {
	// contains filtered or unexported fields
}

OwnsInput represents the information set by Owns method.

type Reconciler

type Reconciler interface {
	reconcile.Reconciler
	InjectClient(client.Client) error
}

type ReconcilerBuilder

type ReconcilerBuilder func() Reconciler

type WatchesInput

type WatchesInput struct {
	// contains filtered or unexported fields
}

WatchesInput represents the information set by Watches method.

Jump to

Keyboard shortcuts

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