claimbinding

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package claimbinding provides a resource claim binding reconciler.

Index

Constants

View Source
const (
	ReasonBinding = "Managed claim is waiting for managed resource to become bindable"
)

Reasons a resource claim is or is not ready.

Variables

This section is empty.

Functions

func Binding

func Binding() v1alpha1.Condition

Binding returns a condition that indicates the resource claim is currently waiting for its managed resource to become bindable.

func ConfigureNames

func ConfigureNames(_ context.Context, cm resource.Claim, _ resource.Class, mg resource.Managed) error

ConfigureNames configures the name and external name of the supplied managed resource. The managed resource name is derived from the supplied resource claim, in the form {claim-namespace}-{claim-name}-{random-string}. The resource claim's external name annotation, if any, is propagated to the managed resource.

func ConfigureReclaimPolicy

func ConfigureReclaimPolicy(_ context.Context, _ resource.Claim, cs resource.Class, mg resource.Managed) error

ConfigureReclaimPolicy configures the reclaim policy of the supplied managed resource. If the managed resource _already has_ a reclaim policy (for example because one was set by another configurator) it is respected. Otherwise the reclaim policy is copied from the resource class. If the resource class does not specify a reclaim policy, the managed resource's policy is set to "Delete".

func ControllerName added in v0.5.0

func ControllerName(kind string) string

ControllerName returns the recommended name for controllers that use this package to reconcile a particular kind of resource claim.

Types

type APIBinder

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

An APIBinder binds resources to claims by updating them in a Kubernetes API server. Note that APIBinder does not support objects using the status subresource; such objects should use APIStatusBinder.

func NewAPIBinder

func NewAPIBinder(c client.Client, t runtime.ObjectTyper) *APIBinder

NewAPIBinder returns a new APIBinder.

func (*APIBinder) Bind

Bind the supplied resource to the supplied claim.

func (*APIBinder) Unbind

func (a *APIBinder) Unbind(ctx context.Context, _ resource.Claim, mg resource.Managed) error

Unbind the supplied Claim from the supplied Managed resource by removing the managed resource's claim reference, transitioning it to binding phase "Released", and if the managed resource's reclaim policy is "Delete", deleting it.

type APIClaimFinalizer

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

An APIClaimFinalizer adds and removes finalizers to and from a claim.

func NewAPIClaimFinalizer

func NewAPIClaimFinalizer(c client.Client, finalizer string) *APIClaimFinalizer

NewAPIClaimFinalizer returns a new APIClaimFinalizer.

func (*APIClaimFinalizer) AddFinalizer

func (a *APIClaimFinalizer) AddFinalizer(ctx context.Context, cm resource.Claim) error

AddFinalizer to the supplied Claim.

func (*APIClaimFinalizer) RemoveFinalizer

func (a *APIClaimFinalizer) RemoveFinalizer(ctx context.Context, cm resource.Claim) error

RemoveFinalizer from the supplied Claim.

type APIManagedCreator

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

An APIManagedCreator creates resources by submitting them to a Kubernetes API server.

func NewAPIManagedCreator

func NewAPIManagedCreator(c client.Client, t runtime.ObjectTyper) *APIManagedCreator

NewAPIManagedCreator returns a new APIManagedCreator.

func (*APIManagedCreator) Create

Create the supplied resource using the supplied class and claim.

type APIStatusBinder

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

An APIStatusBinder binds resources to claims by updating them in a Kubernetes API server. Note that APIStatusBinder does not support objects that do not use the status subresource; such objects should use APIBinder.

func NewAPIStatusBinder

func NewAPIStatusBinder(c client.Client, t runtime.ObjectTyper) *APIStatusBinder

NewAPIStatusBinder returns a new APIStatusBinder.

func (*APIStatusBinder) Bind

Bind the supplied resource to the supplied claim.

func (*APIStatusBinder) Unbind

Unbind the supplied Claim from the supplied Managed resource by removing the managed resource's claim reference, transitioning it to binding phase "Released", and if the managed resource's reclaim policy is "Delete", deleting it.

type Binder

type Binder interface {
	// Bind the supplied Claim to the supplied Managed resource.
	Bind(ctx context.Context, cm resource.Claim, mg resource.Managed) error

	// Unbind the supplied Claim from the supplied Managed resource.
	Unbind(ctx context.Context, cm resource.Claim, mg resource.Managed) error
}

A Binder binds a resource claim to a managed resource.

type BinderFns

type BinderFns struct {
	BindFn   func(ctx context.Context, cm resource.Claim, mg resource.Managed) error
	UnbindFn func(ctx context.Context, cm resource.Claim, mg resource.Managed) error
}

BinderFns satisfy the Binder interface.

func (BinderFns) Bind

Bind the supplied Claim to the supplied Managed resource.

func (BinderFns) Unbind

func (b BinderFns) Unbind(ctx context.Context, cm resource.Claim, mg resource.Managed) error

Unbind the supplied Claim from the supplied Managed resource.

type ClaimFinalizer

type ClaimFinalizer interface {
	// AddFinalizer to the supplied Claim.
	AddFinalizer(ctx context.Context, cm resource.Claim) error

	// RemoveFinalizer from the supplied Claim.
	RemoveFinalizer(ctx context.Context, cm resource.Claim) error
}

A ClaimFinalizer finalizes the deletion of a resource claim.

type ClaimFinalizerFns

type ClaimFinalizerFns struct {
	AddFinalizerFn    func(ctx context.Context, cm resource.Claim) error
	RemoveFinalizerFn func(ctx context.Context, cm resource.Claim) error
}

A ClaimFinalizerFns satisfy the ClaimFinalizer interface.

func (ClaimFinalizerFns) AddFinalizer

func (f ClaimFinalizerFns) AddFinalizer(ctx context.Context, cm resource.Claim) error

AddFinalizer to the supplied Claim.

func (ClaimFinalizerFns) RemoveFinalizer

func (f ClaimFinalizerFns) RemoveFinalizer(ctx context.Context, cm resource.Claim) error

RemoveFinalizer from the supplied Claim.

type ConfiguratorChain

type ConfiguratorChain []ManagedConfigurator

A ConfiguratorChain chains multiple configurators.

func (ConfiguratorChain) Configure

Configure calls each ManagedConfigurator serially. It returns the first error it encounters, if any.

type ManagedConfigurator

type ManagedConfigurator interface {
	Configure(ctx context.Context, cm resource.Claim, cs resource.Class, mg resource.Managed) error
}

A ManagedConfigurator configures a resource, typically by converting it to a known type and populating its spec.

type ManagedConfiguratorFn

type ManagedConfiguratorFn func(ctx context.Context, cm resource.Claim, cs resource.Class, mg resource.Managed) error

A ManagedConfiguratorFn is a function that satisfies the ManagedConfigurator interface.

func (ManagedConfiguratorFn) Configure

Configure the supplied resource using the supplied claim and class.

type ManagedCreator

type ManagedCreator interface {
	Create(ctx context.Context, cm resource.Claim, cs resource.Class, mg resource.Managed) error
}

A ManagedCreator creates a resource, typically by submitting it to an API server. ManagedCreators must not modify the supplied resource class, but are responsible for final modifications to the claim and resource, for example ensuring resource, class, claim, and owner references are set.

type ManagedCreatorFn

type ManagedCreatorFn func(ctx context.Context, cm resource.Claim, cs resource.Class, mg resource.Managed) error

A ManagedCreatorFn is a function that satisfies the ManagedCreator interface.

func (ManagedCreatorFn) Create

Create the supplied resource.

type ObjectMetaConfigurator

type ObjectMetaConfigurator struct{}

An ObjectMetaConfigurator sets standard object metadata for a dynamically provisioned resource, deriving it from a class and claim. It is deprecated; use ConfigureNames instead.

func NewObjectMetaConfigurator

func NewObjectMetaConfigurator(_ runtime.ObjectTyper) *ObjectMetaConfigurator

NewObjectMetaConfigurator returns a new ObjectMetaConfigurator.

func (*ObjectMetaConfigurator) Configure

Configure the supplied Managed resource's object metadata.

type Reconciler

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

A Reconciler reconciles resource claims by creating exactly one kind of concrete managed resource. Each resource claim kind should create an instance of this controller for each managed resource kind they can bind to, using watch predicates to ensure each controller is responsible for exactly one type of resource class provisioner. Each controller must watch its subset of resource claims and any managed resources they control.

func NewReconciler

NewReconciler returns a Reconciler that reconciles resource claims of the supplied ClaimKind with resources of the supplied ManagedKind. It panics if asked to reconcile a claim or resource kind that is not registered with the supplied manager's runtime.Scheme. The returned Reconciler will apply only the ObjectMetaConfigurator by default; most callers should supply one or more ManagedConfigurators to configure their managed resources.

func (*Reconciler) Reconcile

func (r *Reconciler) Reconcile(req reconcile.Request) (reconcile.Result, error)

Reconcile a resource claim with a concrete managed resource.

type ReconcilerOption

type ReconcilerOption func(*Reconciler)

A ReconcilerOption configures a Reconciler.

func WithBinder

func WithBinder(b Binder) ReconcilerOption

WithBinder specifies which Binder should be used to bind resources to their claim.

func WithClaimFinalizer

func WithClaimFinalizer(f ClaimFinalizer) ReconcilerOption

WithClaimFinalizer specifies which ClaimFinalizer should be used to finalize claims when they are deleted.

func WithLogger added in v0.5.0

func WithLogger(l logging.Logger) ReconcilerOption

WithLogger specifies how the Reconciler should log messages.

func WithManagedConfigurators

func WithManagedConfigurators(c ...ManagedConfigurator) ReconcilerOption

WithManagedConfigurators specifies which configurators should be used to configure each managed resource. Configurators will be applied in the order they are specified.

func WithManagedConnectionPropagator

func WithManagedConnectionPropagator(p resource.ManagedConnectionPropagator) ReconcilerOption

WithManagedConnectionPropagator specifies which ManagedConnectionPropagator should be used to propagate resource connection details to their claim.

func WithManagedCreator

func WithManagedCreator(c ManagedCreator) ReconcilerOption

WithManagedCreator specifies which ManagedCreator should be used to create managed resources.

func WithRecorder added in v0.5.0

func WithRecorder(er event.Recorder) ReconcilerOption

WithRecorder specifies how the Reconciler should record events.

Jump to

Keyboard shortcuts

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