resource

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2019 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package resource provides types and functions that can be used to build Kubernetes controllers that reconcile Crossplane resources.

Index

Constants

View Source
const (
	AnnotationKeyPropagateToNamespace = "crossplane.io/propagate-to-namespace"
	AnnotationKeyPropagateToName      = "crossplane.io/propagate-to-name"
	AnnotationKeyPropagateToUID       = "crossplane.io/propagate-to-uid"
)

Supported resources with all of these annotations will be fully or partially propagated to the named resource of the same kind, assuming it exists and consents to propagation.

View Source
const (
	AnnotationKeyPropagateFromNamespace = "crossplane.io/propagate-from-namespace"
	AnnotationKeyPropagateFromName      = "crossplane.io/propagate-from-name"
	AnnotationKeyPropagateFromUID       = "crossplane.io/propagate-from-uid"
)

Supported resources with all of these annotations consent to be fully or partially propagated from the named resource of the same kind.

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 added in v0.2.3

func ConfigureNames(_ context.Context, cm Claim, _ Class, mg 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 added in v0.2.3

func ConfigureReclaimPolicy(_ context.Context, _ Claim, cs Class, mg 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 ConnectionSecretFor

func ConnectionSecretFor(o ConnectionSecretOwner, kind schema.GroupVersionKind) *corev1.Secret

ConnectionSecretFor creates a connection for the supplied ConnectionSecretOwner, assumed to be of the supplied kind. The secret is written to 'default' namespace if the ConnectionSecretOwner does not specify a namespace.

func GetKind

GetKind returns the GroupVersionKind of the supplied object. It return an error if the object is unknown to the supplied ObjectTyper, the object is unversioned, or the object does not have exactly one registered kind.

func Ignore

func Ignore(is ErrorIs, err error) error

Ignore any errors that satisfy the supplied ErrorIs function by returning nil. Errors that do not satisfy the suppled function are returned unmodified.

func IgnoreNotFound

func IgnoreNotFound(err error) error

IgnoreNotFound returns the supplied error, or nil if the error indicates a Kubernetes resource was not found.

func IsBindable

func IsBindable(b Bindable) bool

IsBindable returns true if the supplied Bindable is ready for binding to another Bindable, such as a resource claim or managed resource.

func IsBound

func IsBound(b Bindable) bool

IsBound returns true if the supplied Bindable is bound to another Bindable, such as a resource claim or managed resource.

func IsConditionTrue

func IsConditionTrue(c v1alpha1.Condition) bool

IsConditionTrue returns if condition status is true

func IsReferencesAccessError

func IsReferencesAccessError(err error) bool

IsReferencesAccessError returns true if the given error indicates that some of the `AttributeReferencer` fields are referring to objects that are not accessible, either they are not ready or they do not yet exist

func LocalConnectionSecretFor

func LocalConnectionSecretFor(o LocalConnectionSecretOwner, kind schema.GroupVersionKind) *corev1.Secret

LocalConnectionSecretFor creates a connection secret in the namespace of the supplied LocalConnectionSecretOwner, assumed to be of the supplied kind.

func MustCreateObject

func MustCreateObject(kind schema.GroupVersionKind, oc runtime.ObjectCreater) runtime.Object

MustCreateObject returns a new Object of the supplied kind. It panics if the kind is unknown to the supplied ObjectCreator.

func MustGetKind

MustGetKind returns the GroupVersionKind of the supplied object. It panics if the object is unknown to the supplied ObjectTyper, the object is unversioned, or the object does not have exactly one registered kind.

func NewPredicates

func NewPredicates(fn PredicateFn) predicate.Funcs

NewPredicates returns a set of Funcs that are all satisfied by the supplied PredicateFn. The PredicateFn is run against the new object during updates.

func NewSecretPropagatingReconciler

func NewSecretPropagatingReconciler(m manager.Manager) reconcile.Reconciler

NewSecretPropagatingReconciler returns a Reconciler that reconciles secrets by propagating their data to another secret. Both secrets must consent to this process by including propagation annotations. The Reconciler assumes it has a watch on both propagating (from) and propagated (to) secrets.

func ResolveClassClaimValues

func ResolveClassClaimValues(classValue, claimValue string) (string, error)

ResolveClassClaimValues validates the supplied claim value against the supplied resource class value. If both are non-zero they must match.

func SetBindable

func SetBindable(b Bindable)

SetBindable indicates that the supplied Bindable is ready for binding to another Bindable, such as a resource claim or managed resource by setting its binding phase to "Unbound". It is a no-op for Bindables in phases "Bound" or "Released", because these phases may not transition back to "Unbound".

Types

type APIBinder added in v0.2.0

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 added in v0.2.0

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

NewAPIBinder returns a new APIBinder.

func (*APIBinder) Bind added in v0.2.0

func (a *APIBinder) Bind(ctx context.Context, cm Claim, mg Managed) error

Bind the supplied resource to the supplied claim.

func (*APIBinder) Unbind added in v0.2.0

func (a *APIBinder) Unbind(ctx context.Context, _ Claim, mg 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 added in v0.2.0

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

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

func NewAPIClaimFinalizer added in v0.2.0

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

NewAPIClaimFinalizer returns a new APIClaimFinalizer.

func (*APIClaimFinalizer) AddFinalizer added in v0.2.0

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

AddFinalizer to the supplied Claim.

func (*APIClaimFinalizer) RemoveFinalizer added in v0.2.0

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

RemoveFinalizer from the supplied Claim.

type APIManagedConnectionPropagator

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

An APIManagedConnectionPropagator propagates connection details by reading them from and writing them to a Kubernetes API server.

func NewAPIManagedConnectionPropagator

func NewAPIManagedConnectionPropagator(c client.Client, t runtime.ObjectTyper) *APIManagedConnectionPropagator

NewAPIManagedConnectionPropagator returns a new APIManagedConnectionPropagator.

func (*APIManagedConnectionPropagator) PropagateConnection

func (a *APIManagedConnectionPropagator) PropagateConnection(ctx context.Context, cm Claim, mg Managed) error

PropagateConnection details from the supplied resource to 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

func (a *APIManagedCreator) Create(ctx context.Context, cm Claim, cs Class, mg Managed) error

Create the supplied resource using the supplied class and claim.

type APIManagedFinalizer added in v0.2.0

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

An APIManagedFinalizer adds and removes finalizers to and from a resource.

func NewAPIManagedFinalizer added in v0.2.0

func NewAPIManagedFinalizer(c client.Client, finalizer string) *APIManagedFinalizer

NewAPIManagedFinalizer returns a new APIManagedFinalizer.

func (*APIManagedFinalizer) AddFinalizer added in v0.2.0

func (a *APIManagedFinalizer) AddFinalizer(ctx context.Context, mg Managed) error

AddFinalizer to the supplied Managed resource.

func (*APIManagedFinalizer) RemoveFinalizer added in v0.2.0

func (a *APIManagedFinalizer) RemoveFinalizer(ctx context.Context, mg Managed) error

RemoveFinalizer from the supplied Managed resource.

type APIManagedReferenceResolver

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

An APIManagedReferenceResolver finds and resolves a resource's references, then updates it in the Kubernetes API.

func NewAPIManagedReferenceResolver

func NewAPIManagedReferenceResolver(c client.Client, o ...APIManagedReferenceResolverOption) *APIManagedReferenceResolver

NewAPIManagedReferenceResolver returns an APIManagedReferenceResolver. The resolver uses reflection to recursively finds all pointer types in a struct that satisfy AttributeReferencer by default. It assesses only pointers, structs, and slices because it is assumed that only struct fields or slice elements that are pointers to a struct will satisfy AttributeReferencer.

func (*APIManagedReferenceResolver) ResolveReferences

func (r *APIManagedReferenceResolver) ResolveReferences(ctx context.Context, res CanReference) error

ResolveReferences resolves references made to other managed resources

type APIManagedReferenceResolverOption added in v0.2.0

type APIManagedReferenceResolverOption func(*APIManagedReferenceResolver)

An APIManagedReferenceResolverOption configures an APIManagedReferenceResolver.

func WithAttributeReferencerFinder added in v0.2.0

func WithAttributeReferencerFinder(f AttributeReferencerFinder) APIManagedReferenceResolverOption

WithAttributeReferencerFinder specifies an AttributeReferencerFinder used to find AttributeReferencers.

type APISecretPublisher

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

An APISecretPublisher publishes ConnectionDetails by submitting a Secret to a Kubernetes API server.

func NewAPISecretPublisher

func NewAPISecretPublisher(c client.Client, ot runtime.ObjectTyper) *APISecretPublisher

NewAPISecretPublisher returns a new APISecretPublisher.

func (*APISecretPublisher) PublishConnection

func (a *APISecretPublisher) PublishConnection(ctx context.Context, mg Managed, c ConnectionDetails) error

PublishConnection publishes the supplied ConnectionDetails to a Secret in the same namespace as the supplied Managed resource. Applying is a no-op if the secret already exists with the supplied ConnectionDetails.

func (*APISecretPublisher) UnpublishConnection

func (a *APISecretPublisher) UnpublishConnection(ctx context.Context, mg Managed, c ConnectionDetails) error

UnpublishConnection is no-op since PublishConnection only creates resources that will be garbage collected by Kubernetes when the managed resource is deleted.

type APIStatusBinder added in v0.2.0

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 added in v0.2.0

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

NewAPIStatusBinder returns a new APIStatusBinder.

func (*APIStatusBinder) Bind added in v0.2.0

func (a *APIStatusBinder) Bind(ctx context.Context, cm Claim, mg Managed) error

Bind the supplied resource to the supplied claim.

func (*APIStatusBinder) Unbind added in v0.2.0

func (a *APIStatusBinder) Unbind(ctx context.Context, _ Claim, mg 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 AttributeReferencer

type AttributeReferencer interface {
	// GetStatus retries the referenced resource, as well as other non-managed
	// resources (like a `Provider`) and reports their readiness for use as a
	// referenced resource.
	GetStatus(ctx context.Context, res CanReference, r client.Reader) ([]ReferenceStatus, error)

	// Build retrieves the referenced resource, as well as other non-managed
	// resources (like a `Provider`), and builds the referenced attribute,
	// returning it as a string value.
	Build(ctx context.Context, res CanReference, r client.Reader) (value string, err error)

	// Assign accepts a managed resource object, and assigns the given value to
	// its corresponding property.
	Assign(res CanReference, value string) error
}

An AttributeReferencer resolves cross-resource attribute references. See https://github.com/crossplaneio/crossplane/blob/master/design/one-pager-cross-resource-referencing.md for more information

type AttributeReferencerFinder added in v0.2.0

type AttributeReferencerFinder interface {
	FindReferencers(obj interface{}) []AttributeReferencer
}

An AttributeReferencerFinder returns all types within the supplied object that satisfy AttributeReferencer.

type AttributeReferencerFinderFn added in v0.2.0

type AttributeReferencerFinderFn func(obj interface{}) []AttributeReferencer

An AttributeReferencerFinderFn satisfies AttributeReferencerFinder.

func (AttributeReferencerFinderFn) FindReferencers added in v0.2.0

func (fn AttributeReferencerFinderFn) FindReferencers(obj interface{}) []AttributeReferencer

FindReferencers finds all AttributeReferencers.

type Bindable

type Bindable interface {
	SetBindingPhase(p v1alpha1.BindingPhase)
	GetBindingPhase() v1alpha1.BindingPhase
}

A Bindable resource may be bound to another resource. Resources are bindable when they available for use.

type Binder added in v0.2.0

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

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

A Binder binds a resource claim to a managed resource.

type BinderFns added in v0.2.0

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

BinderFns satisfy the Binder interface.

func (BinderFns) Bind added in v0.2.0

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

Bind the supplied Claim to the supplied Managed resource.

func (BinderFns) Unbind added in v0.2.0

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

Unbind the supplied Claim from the supplied Managed resource.

type CanReference

type CanReference runtime.Object

A CanReference is a resource that can reference another resource in its spec in order to automatically resolve corresponding spec field values by inspecting the referenced resource.

type Claim

A Claim is a Kubernetes object representing an abstract resource claim (e.g. an SQL database) that may be bound to a concrete managed resource (e.g. a CloudSQL instance).

type ClaimDefaultingReconciler

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

A ClaimDefaultingReconciler reconciles resource claims by setting their class reference to the resource class annotated as the default. If multiple classes are annotated as the default one of the annotated classes will be set, but which one is undefined.

func NewClaimDefaultingReconciler

func NewClaimDefaultingReconciler(m manager.Manager, of ClaimKind, to ClassKind, o ...ClaimDefaultingReconcilerOption) *ClaimDefaultingReconciler

NewClaimDefaultingReconciler returns a ClaimDefaultingReconciler that sets the class reference of a resource claim to the resource class annotated as the default.

func (*ClaimDefaultingReconciler) Reconcile

Reconcile a resource claim by using its class selector to select and allocate it a resource class.

type ClaimDefaultingReconcilerOption

type ClaimDefaultingReconcilerOption func(*ClaimDefaultingReconciler)

A ClaimDefaultingReconcilerOption configures a ClaimDefaultingReconciler.

func WithDefaultingJitterer

func WithDefaultingJitterer(j Jitterer) ClaimDefaultingReconcilerOption

WithDefaultingJitterer specifies the Jitterer a ClaimDefaultingReconciler should use.

type ClaimFinalizer

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

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

A ClaimFinalizer finalizes the deletion of a resource claim.

type ClaimFinalizerFns added in v0.2.0

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

A ClaimFinalizerFns satisfy the ClaimFinalizer interface.

func (ClaimFinalizerFns) AddFinalizer added in v0.2.0

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

AddFinalizer to the supplied Claim.

func (ClaimFinalizerFns) RemoveFinalizer added in v0.2.0

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

RemoveFinalizer from the supplied Claim.

type ClaimKind

type ClaimKind schema.GroupVersionKind

A ClaimKind contains the type metadata for a kind of resource claim.

type ClaimReconciler

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

A ClaimReconciler 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 NewClaimReconciler

func NewClaimReconciler(m manager.Manager, of ClaimKind, using ClassKind, with ManagedKind, o ...ClaimReconcilerOption) *ClaimReconciler

NewClaimReconciler returns a ClaimReconciler 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 ClaimReconciler will apply only the ObjectMetaConfigurator by default; most callers should supply one or more ManagedConfigurators to configure their managed resources.

func (*ClaimReconciler) Reconcile

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

Reconcile a resource claim with a concrete managed resource.

type ClaimReconcilerOption

type ClaimReconcilerOption func(*ClaimReconciler)

A ClaimReconcilerOption configures a ClaimReconciler.

func WithBinder added in v0.2.0

func WithBinder(b Binder) ClaimReconcilerOption

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

func WithClaimFinalizer

func WithClaimFinalizer(f ClaimFinalizer) ClaimReconcilerOption

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

func WithManagedConfigurators

func WithManagedConfigurators(c ...ManagedConfigurator) ClaimReconcilerOption

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 ManagedConnectionPropagator) ClaimReconcilerOption

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

func WithManagedCreator

func WithManagedCreator(c ManagedCreator) ClaimReconcilerOption

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

type ClaimReferencer

type ClaimReferencer interface {
	SetClaimReference(r *corev1.ObjectReference)
	GetClaimReference() *corev1.ObjectReference
}

A ClaimReferencer may reference a resource claim.

type ClaimSchedulingReconciler

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

A ClaimSchedulingReconciler schedules resource claims to a resource class that matches their class selector. Claims are reconciled by randomly selecting a matching resource class and attempting to set it as the claim's class reference. The ClaimSchedulingReconciler is designed for use in claim scheduling controllers that race several others to schedule a claim.

func NewClaimSchedulingReconciler

func NewClaimSchedulingReconciler(m manager.Manager, of ClaimKind, to ClassKind, o ...ClaimSchedulingReconcilerOption) *ClaimSchedulingReconciler

NewClaimSchedulingReconciler returns a ClaimSchedulingReconciler that schedules resource claims to a resource class that matches their class selector.

func (*ClaimSchedulingReconciler) Reconcile

Reconcile a resource claim by using its class selector to select and allocate it a resource class.

type ClaimSchedulingReconcilerOption

type ClaimSchedulingReconcilerOption func(*ClaimSchedulingReconciler)

A ClaimSchedulingReconcilerOption configures a ClaimSchedulingReconciler.

func WithSchedulingJitterer

func WithSchedulingJitterer(j Jitterer) ClaimSchedulingReconcilerOption

WithSchedulingJitterer specifies the Jitterer a ClaimSchedulingReconciler should use.

type Class

type Class interface {
	runtime.Object
	metav1.Object

	Reclaimer
}

A Class is a Kubernetes object representing configuration specifications for a managed resource.

type ClassKind

type ClassKind schema.GroupVersionKind

A ClassKind contains the type metadata for a kind of resource class.

func (ClassKind) List

List returns the list kind associated with a ClassKind.

type ClassReferencer

type ClassReferencer interface {
	SetClassReference(r *corev1.ObjectReference)
	GetClassReference() *corev1.ObjectReference
}

A ClassReferencer may reference a resource class.

type ClassSelector

type ClassSelector interface {
	SetClassSelector(s *metav1.LabelSelector)
	GetClassSelector() *metav1.LabelSelector
}

A ClassSelector may reference a resource class.

type Conditioned

type Conditioned interface {
	SetConditions(c ...v1alpha1.Condition)
	GetCondition(v1alpha1.ConditionType) v1alpha1.Condition
}

A Conditioned may have conditions set or retrieved. Conditions are typically indicate the status of both a resource and its reconciliation process.

type ConfiguratorChain

type ConfiguratorChain []ManagedConfigurator

A ConfiguratorChain chains multiple configurators.

func (ConfiguratorChain) Configure

func (cc ConfiguratorChain) Configure(ctx context.Context, cm Claim, cs Class, mg Managed) error

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

type ConnectionDetails

type ConnectionDetails map[string][]byte

ConnectionDetails created or updated during an operation on an external resource, for example usernames, passwords, endpoints, ports, etc.

type ConnectionSecretOwner

type ConnectionSecretOwner interface {
	metav1.Object
	ConnectionSecretWriterTo
}

A ConnectionSecretOwner may create and manage a connection secret in an arbitrary namespace.

type ConnectionSecretWriterTo

type ConnectionSecretWriterTo interface {
	SetWriteConnectionSecretToReference(r *v1alpha1.SecretReference)
	GetWriteConnectionSecretToReference() *v1alpha1.SecretReference
}

A ConnectionSecretWriterTo may write a connection secret to an arbitrary namespace.

type EnqueueRequestForClaim

type EnqueueRequestForClaim struct{}

EnqueueRequestForClaim enqueues a reconcile.Request for the NamespacedName of a ClaimReferencer's ClaimReference.

func (*EnqueueRequestForClaim) Create

Create adds a NamespacedName for the supplied CreateEvent if its Object is a ClaimReferencer.

func (*EnqueueRequestForClaim) Delete

Delete adds a NamespacedName for the supplied DeleteEvent if its Object is a ClaimReferencer.

func (*EnqueueRequestForClaim) Generic

Generic adds a NamespacedName for the supplied GenericEvent if its Object is a ClaimReferencer.

func (*EnqueueRequestForClaim) Update

Update adds a NamespacedName for the supplied UpdateEvent if its Objects are ClaimReferencers.

type EnqueueRequestForPropagator

type EnqueueRequestForPropagator struct{}

EnqueueRequestForPropagator enqueues a reconcile.Request for the NamespacedName of a propagated object, i.e. an object with propagation metadata annotations.

func (*EnqueueRequestForPropagator) Create

Create adds a NamespacedName for the supplied CreateEvent if its Object is propagated.

func (*EnqueueRequestForPropagator) Delete

Delete adds a NamespacedName for the supplied DeleteEvent if its Object is propagated.

func (*EnqueueRequestForPropagator) Generic

Generic adds a NamespacedName for the supplied GenericEvent if its Object is propagated.

func (*EnqueueRequestForPropagator) Update

Update adds a NamespacedName for the supplied UpdateEvent if its Objects are propagated.

type ErrorIs

type ErrorIs func(err error) bool

An ErrorIs function returns true if an error satisfies a particular condition.

type ExternalClient

type ExternalClient interface {
	// Observe the external resource the supplied Managed resource represents,
	// if any. Observe implementations must not modify the external resource,
	// but may update the supplied Managed resource to reflect the state of the
	// external resource.
	Observe(ctx context.Context, mg Managed) (ExternalObservation, error)

	// Create an external resource per the specifications of the supplied
	// Managed resource. Called when Observe reports that the associated
	// external resource does not exist.
	Create(ctx context.Context, mg Managed) (ExternalCreation, error)

	// Update the external resource represented by the supplied Managed
	// resource, if necessary. Called unless Observe reports that the
	// associated external resource is up to date.
	Update(ctx context.Context, mg Managed) (ExternalUpdate, error)

	// Delete the external resource upon deletion of its associated Managed
	// resource. Called when the managed resource has been deleted.
	Delete(ctx context.Context, mg Managed) error
}

An ExternalClient manages the lifecycle of an external resource. None of the calls here should be blocking. All of the calls should be idempotent. For example, Create call should not return AlreadyExists error if it's called again with the same parameters or Delete call should not return error if there is an ongoing deletion or resource does not exist.

type ExternalClientFns

type ExternalClientFns struct {
	ObserveFn func(ctx context.Context, mg Managed) (ExternalObservation, error)
	CreateFn  func(ctx context.Context, mg Managed) (ExternalCreation, error)
	UpdateFn  func(ctx context.Context, mg Managed) (ExternalUpdate, error)
	DeleteFn  func(ctx context.Context, mg Managed) error
}

ExternalClientFns are a series of functions that satisfy the ExternalClient interface.

func (ExternalClientFns) Create

Create an external resource per the specifications of the supplied Managed resource.

func (ExternalClientFns) Delete

func (e ExternalClientFns) Delete(ctx context.Context, mg Managed) error

Delete the external resource upon deletion of its associated Managed resource.

func (ExternalClientFns) Observe

Observe the external resource the supplied Managed resource represents, if any.

func (ExternalClientFns) Update

Update the external resource represented by the supplied Managed resource, if necessary.

type ExternalConnecter

type ExternalConnecter interface {
	// Connect to the provider specified by the supplied managed resource and
	// produce an ExternalClient.
	Connect(ctx context.Context, mg Managed) (ExternalClient, error)
}

An ExternalConnecter produces a new ExternalClient given the supplied Managed resource.

type ExternalConnectorFn

type ExternalConnectorFn func(ctx context.Context, mg Managed) (ExternalClient, error)

An ExternalConnectorFn is a function that satisfies the ExternalConnecter interface.

func (ExternalConnectorFn) Connect

Connect to the provider specified by the supplied managed resource and produce an ExternalClient.

type ExternalCreation

type ExternalCreation struct {
	ConnectionDetails ConnectionDetails
}

An ExternalCreation is the result of the creation of an external resource.

type ExternalObservation

type ExternalObservation struct {
	ResourceExists    bool
	ResourceUpToDate  bool
	ConnectionDetails ConnectionDetails
}

An ExternalObservation is the result of an observation of an external resource.

type ExternalUpdate

type ExternalUpdate struct {
	ConnectionDetails ConnectionDetails
}

An ExternalUpdate is the result of an update to an external resource.

type InitializerChain

type InitializerChain []ManagedInitializer

A InitializerChain chains multiple managed initializers.

func (InitializerChain) Initialize

func (cc InitializerChain) Initialize(ctx context.Context, mg Managed) error

Initialize calls each ManagedInitializer serially. It returns the first error it encounters, if any.

type Jitterer

type Jitterer func()

A Jitterer sleeps for a random amount of time in order to decrease the chance of any one controller predictably winning the race to schedule claims to a class, for example because it has fewer classes to list and select from than its competitors.

type LocalConnectionSecretOwner

type LocalConnectionSecretOwner interface {
	metav1.Object
	LocalConnectionSecretWriterTo
}

A LocalConnectionSecretOwner may create and manage a connection secret in its own namespace.

type LocalConnectionSecretWriterTo

type LocalConnectionSecretWriterTo interface {
	SetWriteConnectionSecretToReference(r *v1alpha1.LocalSecretReference)
	GetWriteConnectionSecretToReference() *v1alpha1.LocalSecretReference
}

A LocalConnectionSecretWriterTo may write a connection secret to its own namespace.

type Managed

A Managed is a Kubernetes object representing a concrete managed resource (e.g. a CloudSQL instance).

type ManagedConfigurator

type ManagedConfigurator interface {
	Configure(ctx context.Context, cm Claim, cs Class, mg 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 Claim, cs Class, mg Managed) error

A ManagedConfiguratorFn is a function that satisfies the ManagedConfigurator interface.

func (ManagedConfiguratorFn) Configure

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

Configure the supplied resource using the supplied claim and class.

type ManagedConnectionPropagator

type ManagedConnectionPropagator interface {
	PropagateConnection(ctx context.Context, cm Claim, mg Managed) error
}

A ManagedConnectionPropagator is responsible for propagating information required to connect to a managed resource (for example the connection secret) from the managed resource to its resource claim.

type ManagedConnectionPropagatorFn

type ManagedConnectionPropagatorFn func(ctx context.Context, cm Claim, mg Managed) error

A ManagedConnectionPropagatorFn is a function that satisfies the ManagedConnectionPropagator interface.

func (ManagedConnectionPropagatorFn) PropagateConnection

func (fn ManagedConnectionPropagatorFn) PropagateConnection(ctx context.Context, cm Claim, mg Managed) error

PropagateConnection information from the supplied managed resource to the supplied resource claim.

type ManagedConnectionPublisher

type ManagedConnectionPublisher interface {
	// PublishConnection details for the supplied Managed resource. Publishing
	// must be additive; i.e. if details (a, b, c) are published, subsequently
	// publicing details (b, c, d) should update (b, c) but not remove a.
	PublishConnection(ctx context.Context, mg Managed, c ConnectionDetails) error

	// UnpublishConnection details for the supplied Managed resource.
	UnpublishConnection(ctx context.Context, mg Managed, c ConnectionDetails) error
}

A ManagedConnectionPublisher manages the supplied ConnectionDetails for the supplied Managed resource. ManagedPublishers must handle the case in which the supplied ConnectionDetails are empty.

type ManagedConnectionPublisherFns

type ManagedConnectionPublisherFns struct {
	PublishConnectionFn   func(ctx context.Context, mg Managed, c ConnectionDetails) error
	UnpublishConnectionFn func(ctx context.Context, mg Managed, c ConnectionDetails) error
}

ManagedConnectionPublisherFns is the pluggable struct to produce objects with ManagedConnectionPublisher interface.

func (ManagedConnectionPublisherFns) PublishConnection

PublishConnection details for the supplied Managed resource.

func (ManagedConnectionPublisherFns) UnpublishConnection

func (fn ManagedConnectionPublisherFns) UnpublishConnection(ctx context.Context, mg Managed, c ConnectionDetails) error

UnpublishConnection details for the supplied Managed resource.

type ManagedCreator

type ManagedCreator interface {
	Create(ctx context.Context, cm Claim, cs Class, mg 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 Claim, cs Class, mg Managed) error

A ManagedCreatorFn is a function that satisfies the ManagedCreator interface.

func (ManagedCreatorFn) Create

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

Create the supplied resource.

type ManagedFinalizer

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

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

A ManagedFinalizer finalizes the deletion of a resource claim.

type ManagedFinalizerFns added in v0.2.0

type ManagedFinalizerFns struct {
	AddFinalizerFn    func(ctx context.Context, cm Managed) error
	RemoveFinalizerFn func(ctx context.Context, cm Managed) error
}

A ManagedFinalizerFns satisfy the ManagedFinalizer interface.

func (ManagedFinalizerFns) AddFinalizer added in v0.2.0

func (f ManagedFinalizerFns) AddFinalizer(ctx context.Context, mg Managed) error

AddFinalizer to the supplied Managed resource.

func (ManagedFinalizerFns) RemoveFinalizer added in v0.2.0

func (f ManagedFinalizerFns) RemoveFinalizer(ctx context.Context, mg Managed) error

RemoveFinalizer from the supplied Managed resource.

type ManagedInitializer

type ManagedInitializer interface {
	Initialize(ctx context.Context, mg Managed) error
}

A ManagedInitializer establishes ownership of the supplied Managed resource. This typically involves the operations that are run before calling any ExternalClient methods.

type ManagedInitializerFn

type ManagedInitializerFn func(ctx context.Context, mg Managed) error

A ManagedInitializerFn is a function that satisfies the ManagedInitializer interface.

func (ManagedInitializerFn) Initialize

func (m ManagedInitializerFn) Initialize(ctx context.Context, mg Managed) error

Initialize calls ManagedInitializerFn function.

type ManagedKind

type ManagedKind schema.GroupVersionKind

A ManagedKind contains the type metadata for a kind of managed resource.

type ManagedNameAsExternalName

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

ManagedNameAsExternalName writes the name of the managed resource to the external name annotation field in order to be used as name of the external resource in provider.

func NewManagedNameAsExternalName

func NewManagedNameAsExternalName(c client.Client) *ManagedNameAsExternalName

NewManagedNameAsExternalName returns a new ManagedNameAsExternalName.

func (*ManagedNameAsExternalName) Initialize

func (a *ManagedNameAsExternalName) Initialize(ctx context.Context, mg Managed) error

Initialize the given managed resource.

type ManagedReconciler

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

A ManagedReconciler reconciles managed resources by creating and managing the lifecycle of an external resource, i.e. a resource in an external system such as a cloud provider API. Each controller must watch the managed resource kind for which it is responsible.

func NewManagedReconciler

func NewManagedReconciler(m manager.Manager, of ManagedKind, o ...ManagedReconcilerOption) *ManagedReconciler

NewManagedReconciler returns a ManagedReconciler that reconciles managed resources of the supplied ManagedKind with resources in an external system such as a cloud provider API. It panics if asked to reconcile a managed resource kind that is not registered with the supplied manager's runtime.Scheme. The returned ManagedReconciler reconciles with a dummy, no-op 'external system' by default; callers should supply an ExternalConnector that returns an ExternalClient capable of managing resources in a real system.

func (*ManagedReconciler) Reconcile

Reconcile a managed resource with an external resource.

type ManagedReconcilerOption

type ManagedReconcilerOption func(*ManagedReconciler)

A ManagedReconcilerOption configures a ManagedReconciler.

func WithExternalConnecter

func WithExternalConnecter(c ExternalConnecter) ManagedReconcilerOption

WithExternalConnecter specifies how the Reconciler should connect to the API used to sync and delete external resources.

func WithLongWait

func WithLongWait(after time.Duration) ManagedReconcilerOption

WithLongWait specifies how long the ManagedReconciler should wait before queueing a new reconciliation in 'long wait' scenarios. The Reconciler requeues after a long wait when it is not actively waiting for an external operation, but wishes to check whether an existing external resource needs to be synced to its Crossplane Managed resource.

func WithManagedConnectionPublishers

func WithManagedConnectionPublishers(p ...ManagedConnectionPublisher) ManagedReconcilerOption

WithManagedConnectionPublishers specifies how the Reconciler should publish its connection details such as credentials and endpoints.

func WithManagedFinalizer

func WithManagedFinalizer(f ManagedFinalizer) ManagedReconcilerOption

WithManagedFinalizer specifies how the Reconciler should add and remove finalizers to and from the managed resource.

func WithManagedInitializers

func WithManagedInitializers(i ...ManagedInitializer) ManagedReconcilerOption

WithManagedInitializers specifies how the Reconciler should initialize a managed resource before calling any of the ExternalClient functions.

func WithManagedReferenceResolver added in v0.2.0

func WithManagedReferenceResolver(rr ManagedReferenceResolver) ManagedReconcilerOption

WithManagedReferenceResolver specifies how the Reconciler should resolve any inter-resource references it encounters while reconciling managed resources.

func WithShortWait

func WithShortWait(after time.Duration) ManagedReconcilerOption

WithShortWait specifies how long the ManagedReconciler should wait before queueing a new reconciliation in 'short wait' scenarios. The Reconciler requeues after a short wait when it knows it is waiting for an external operation to complete, or when it encounters a potentially temporary error.

type ManagedReferenceResolver

type ManagedReferenceResolver interface {
	// ResolveReferences finds all fields in the supplied CanReference that are
	// references to Kubernetes resources, then uses the fields of those
	// resources to update corresponding fields in CanReference, for example
	// setting .spec.network to the name of the Network resource specified as
	// .spec.networkRef.
	ResolveReferences(ctx context.Context, res CanReference) error
}

A ManagedReferenceResolver resolves references to other managed resources.

type ManagedReferenceResolverFn

type ManagedReferenceResolverFn func(context.Context, CanReference) error

A ManagedReferenceResolverFn is a function that satisfies the ManagedReferenceResolver interface.

func (ManagedReferenceResolverFn) ResolveReferences

func (m ManagedReferenceResolverFn) ResolveReferences(ctx context.Context, res CanReference) error

ResolveReferences calls ManagedReferenceResolverFn function

type ManagedResourceReferencer

type ManagedResourceReferencer interface {
	SetResourceReference(r *corev1.ObjectReference)
	GetResourceReference() *corev1.ObjectReference
}

A ManagedResourceReferencer may reference a concrete managed resource.

type NopClient

type NopClient struct{}

A NopClient does nothing.

func (*NopClient) Create

func (c *NopClient) Create(ctx context.Context, mg Managed) (ExternalCreation, error)

Create does nothing. It returns an empty ExternalCreation and no error.

func (*NopClient) Delete

func (c *NopClient) Delete(ctx context.Context, mg Managed) error

Delete does nothing. It never returns an error.

func (*NopClient) Observe

func (c *NopClient) Observe(ctx context.Context, mg Managed) (ExternalObservation, error)

Observe does nothing. It returns an empty ExternalObservation and no error.

func (*NopClient) Update

func (c *NopClient) Update(ctx context.Context, mg Managed) (ExternalUpdate, error)

Update does nothing. It returns an empty ExternalUpdate and no error.

type NopConnecter

type NopConnecter struct{}

A NopConnecter does nothing.

func (*NopConnecter) Connect

Connect returns a NopClient. It never returns an error.

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

func (c *ObjectMetaConfigurator) Configure(ctx context.Context, cm Claim, cs Class, mg Managed) error

Configure the supplied Managed resource's object metadata.

type PredicateFn

type PredicateFn func(obj runtime.Object) bool

A PredicateFn returns true if the supplied object should be reconciled.

func AllOf

func AllOf(fn ...PredicateFn) PredicateFn

AllOf accepts objects that pass all of the supplied predicate functions.

func AnyOf

func AnyOf(fn ...PredicateFn) PredicateFn

AnyOf accepts objects that pass any of the supplied predicate functions.

func HasClassReferenceKind

func HasClassReferenceKind(k ClassKind) PredicateFn

HasClassReferenceKind accepts objects that reference the supplied resource class kind.

func HasClassSelector

func HasClassSelector() PredicateFn

HasClassSelector accepts resource claims that do not specify a resource class selector.

func HasManagedResourceReferenceKind

func HasManagedResourceReferenceKind(k ManagedKind) PredicateFn

HasManagedResourceReferenceKind accepts objects that reference the supplied managed resource kind.

func HasNoClassReference

func HasNoClassReference() PredicateFn

HasNoClassReference accepts resource claims that do not reference a specific resource class.

func HasNoClassSelector

func HasNoClassSelector() PredicateFn

HasNoClassSelector accepts resource claims that do not specify a resource class selector.

func HasNoManagedResourceReference

func HasNoManagedResourceReference() PredicateFn

HasNoManagedResourceReference accepts resource claims that do not reference a specific managed resource.

func IsControlledByKind

func IsControlledByKind(k schema.GroupVersionKind) PredicateFn

IsControlledByKind accepts objects that are controlled by a resource of the supplied kind.

func IsManagedKind

func IsManagedKind(k ManagedKind, ot runtime.ObjectTyper) PredicateFn

IsManagedKind accepts objects that are of the supplied managed resource kind.

func IsPropagated

func IsPropagated() PredicateFn

IsPropagated accepts objects that consent to be partially or fully propagated from another object of the same kind.

func IsPropagator

func IsPropagator() PredicateFn

IsPropagator accepts objects that request to be partially or fully propagated to another object of the same kind.

type PublisherChain

type PublisherChain []ManagedConnectionPublisher

A PublisherChain chains multiple ManagedPublishers.

func (PublisherChain) PublishConnection

func (pc PublisherChain) PublishConnection(ctx context.Context, mg Managed, c ConnectionDetails) error

PublishConnection calls each ManagedConnectionPublisher.PublishConnection serially. It returns the first error it encounters, if any.

func (PublisherChain) UnpublishConnection

func (pc PublisherChain) UnpublishConnection(ctx context.Context, mg Managed, c ConnectionDetails) error

UnpublishConnection calls each ManagedConnectionPublisher.UnpublishConnection serially. It returns the first error it encounters, if any.

type Reclaimer

type Reclaimer interface {
	SetReclaimPolicy(p v1alpha1.ReclaimPolicy)
	GetReclaimPolicy() v1alpha1.ReclaimPolicy
}

A Reclaimer may specify a ReclaimPolicy.

type ReferenceStatus

type ReferenceStatus struct {
	Name   string
	Status ReferenceStatusType
}

ReferenceStatus has the name and status of a reference

func (ReferenceStatus) String

func (r ReferenceStatus) String() string

type ReferenceStatusType

type ReferenceStatusType int

ReferenceStatusType is an enum type for the possible values for a Reference Status

const (
	// ReferenceStatusUnknown is the default value
	ReferenceStatusUnknown ReferenceStatusType = iota
	// ReferenceNotFound shows that the reference is not found
	ReferenceNotFound
	// ReferenceNotReady shows that the reference is not ready
	ReferenceNotReady
	// ReferenceReady shows that the reference is ready
	ReferenceReady
)

func (ReferenceStatusType) String

func (t ReferenceStatusType) String() string

Jump to

Keyboard shortcuts

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