resource

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2020 License: Apache-2.0 Imports: 18 Imported by: 4,762

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 (
	ExternalResourceTagKeyKind     = "crossplane-kind"
	ExternalResourceTagKeyName     = "crossplane-name"
	ExternalResourceTagKeyClass    = "crossplane-class"
	ExternalResourceTagKeyProvider = "crossplane-provider"
)

External resources are tagged/labelled with the following keys in the cloud provider API if the type supports.

View Source
const SecretTypeConnection corev1.SecretType = "connection.crossplane.io/v1alpha1"

SecretTypeConnection is the type of Crossplane connection secrets.

Variables

This section is empty.

Functions

func Apply deprecated

func Apply(ctx context.Context, c client.Client, o runtime.Object, ao ...ApplyOption) error

Apply changes to the supplied object. The object will be created if it does not exist, or patched if it does.

Deprecated: use APIPatchingApplicator instead.

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 GetExternalTags

func GetExternalTags(mg Managed) map[string]string

GetExternalTags returns the identifying tags to be used to tag the external resource in provider API.

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

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

func IsConditionTrue

func IsConditionTrue(c v1alpha1.Condition) bool

IsConditionTrue returns if condition status is true

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

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

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

func NewAPIConnectionPropagator added in v0.8.0

func NewAPIConnectionPropagator(c client.Client, t runtime.ObjectTyper) *APIConnectionPropagator

NewAPIConnectionPropagator returns a new APIConnectionPropagator.

func (*APIConnectionPropagator) PropagateConnection added in v0.8.0

PropagateConnection details from the supplied resource.

type APIFinalizer added in v0.8.0

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

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

func NewAPIFinalizer added in v0.8.0

func NewAPIFinalizer(c client.Client, finalizer string) *APIFinalizer

NewAPIFinalizer returns a new APIFinalizer.

func (*APIFinalizer) AddFinalizer added in v0.8.0

func (a *APIFinalizer) AddFinalizer(ctx context.Context, obj Object) error

AddFinalizer to the supplied Managed resource.

func (*APIFinalizer) RemoveFinalizer added in v0.8.0

func (a *APIFinalizer) RemoveFinalizer(ctx context.Context, obj Object) error

RemoveFinalizer from the supplied Managed resource.

type APIManagedConnectionPropagator

type APIManagedConnectionPropagator struct {
	Propagator ConnectionPropagator
}

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

func NewAPIManagedConnectionPropagator deprecated

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

NewAPIManagedConnectionPropagator returns a new APIConnectionPropagator.

Deprecated: Use NewAPIConnectionPropagator.

func (*APIManagedConnectionPropagator) PropagateConnection

PropagateConnection details from the supplied resource.

type APIPatchingApplicator added in v0.7.0

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

An APIPatchingApplicator applies changes to an object by either creating or patching it in a Kubernetes API server.

func NewAPIPatchingApplicator added in v0.7.0

func NewAPIPatchingApplicator(c client.Client) *APIPatchingApplicator

NewAPIPatchingApplicator returns an Applicator that applies changes to an object by either creating or patching it in a Kubernetes API server.

func (*APIPatchingApplicator) Apply added in v0.7.0

Apply changes to the supplied object. The object will be created if it does not exist, or patched if it does.

type APIUpdatingApplicator added in v0.7.0

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

An APIUpdatingApplicator applies changes to an object by either creating or updating it in a Kubernetes API server.

func NewAPIUpdatingApplicator added in v0.7.0

func NewAPIUpdatingApplicator(c client.Client) *APIUpdatingApplicator

NewAPIUpdatingApplicator returns an Applicator that applies changes to an object by either creating or updating it in a Kubernetes API server.

func (*APIUpdatingApplicator) Apply added in v0.7.0

Apply changes to the supplied object. The object will be created if it does not exist, or updated if it does.

type Applicator

type Applicator interface {
	Apply(context.Context, runtime.Object, ...ApplyOption) error
}

An Applicator applies changes to an object.

type ApplyFn

type ApplyFn func(context.Context, runtime.Object, ...ApplyOption) error

An ApplyFn is a function that satisfies the Applicator interface.

func (ApplyFn) Apply

func (fn ApplyFn) Apply(ctx context.Context, o runtime.Object, ao ...ApplyOption) error

Apply changes to the supplied object.

type ApplyOption

type ApplyOption func(ctx context.Context, current, desired runtime.Object) error

An ApplyOption is called before patching the current object to match the desired object. ApplyOptions are not called if no current object exists.

func ConnectionSecretMustBeControllableBy added in v0.7.0

func ConnectionSecretMustBeControllableBy(u types.UID) ApplyOption

ConnectionSecretMustBeControllableBy requires that the current object is a connection secret that is controllable by an object with the supplied UID. Contemporary connection secrets are of SecretTypeConnection, while legacy connection secrets are of corev1.SecretTypeOpaque. Contemporary connection secrets are considered controllable if they are already controlled by the supplied UID, or have no controller reference. Legacy connection secrets are only considered controllable if they are already controlled by the supplied UID. It is not safe to assume legacy connection secrets without a controller reference are controllable because they are indistinguishable from Kubernetes secrets that have nothing to do with Crossplane.

func ControllersMustMatch deprecated

func ControllersMustMatch() ApplyOption

ControllersMustMatch requires the current object to have a controller reference, and for that controller reference to match the controller reference of the desired object.

Deprecated: Use ControllableBy.

func MustBeControllableBy added in v0.7.0

func MustBeControllableBy(u types.UID) ApplyOption

MustBeControllableBy requires that the current object is controllable by an object with the supplied UID. An object is controllable if its controller reference matches the supplied UID, or it has no controller reference.

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/crossplane/crossplane/blob/master/design/one-pager-cross-resource-referencing.md for more information

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 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 ClaimKind

type ClaimKind schema.GroupVersionKind

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

type ClaimList added in v0.8.0

type ClaimList interface {
	runtime.Object

	// GetItems returns the list of resource claims.
	GetItems() []Claim
}

A ClaimList is a list of resource claims.

type ClaimReferencer

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

A ClaimReferencer may reference a resource claim.

type Class

type Class interface {
	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 ClassList added in v0.8.0

type ClassList interface {
	runtime.Object

	// GetItems returns the list of resource classes.
	GetItems() []Class
}

A ClassList is a list of resource classes.

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

type ClientApplicator struct {
	client.Client
	Applicator
}

A ClientApplicator may be used to build a single 'client' that satisfies both client.Client and Applicator.

type Composed added in v0.8.0

type Composed interface {
	Object

	Conditioned
	ConnectionSecretWriterTo
}

Composed resources can be a composed into a Composite resource.

type ComposedResourcesReferencer added in v0.8.0

type ComposedResourcesReferencer interface {
	SetResourceReferences([]corev1.ObjectReference)
	GetResourceReferences() []corev1.ObjectReference
}

A ComposedResourcesReferencer may reference the resources it composes.

type Composite added in v0.8.0

A Composite resource composes one or more Composed resources.

type CompositeKind added in v0.8.0

type CompositeKind schema.GroupVersionKind

A CompositeKind contains the type metadata for a kind of composite resource.

type CompositeResourceReferencer added in v0.8.0

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

A CompositeResourceReferencer can reference a composite resource.

type CompositionReferencer added in v0.8.0

type CompositionReferencer interface {
	SetCompositionReference(*corev1.ObjectReference)
	GetCompositionReference() *corev1.ObjectReference
}

A CompositionReferencer may reference a composition of resources.

type CompositionSelector added in v0.8.0

type CompositionSelector interface {
	SetCompositionSelector(*metav1.LabelSelector)
	GetCompositionSelector() *metav1.LabelSelector
}

A CompositionSelector may select a composition of resources.

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

type ConnectionPropagator interface {
	PropagateConnection(ctx context.Context, to LocalConnectionSecretOwner, from ConnectionSecretOwner) error
}

A ConnectionPropagator is responsible for propagating information required to connect to a resource.

type ConnectionPropagatorFn added in v0.8.0

type ConnectionPropagatorFn func(ctx context.Context, to LocalConnectionSecretOwner, from ConnectionSecretOwner) error

A ConnectionPropagatorFn is a function that satisfies the

ConnectionPropagator interface.

type ConnectionSecretOwner

type ConnectionSecretOwner interface {
	runtime.Object
	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 CredentialsSecretReferencer

type CredentialsSecretReferencer interface {
	GetCredentialsSecretReference() v1alpha1.SecretKeySelector
	SetCredentialsSecretReference(r v1alpha1.SecretKeySelector)
}

A CredentialsSecretReferencer may refer to a credential secret in 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 EnqueueRequestForPropagated

type EnqueueRequestForPropagated struct{}

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

func (*EnqueueRequestForPropagated) Create

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

func (*EnqueueRequestForPropagated) Delete

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

func (*EnqueueRequestForPropagated) Generic

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

func (*EnqueueRequestForPropagated) 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 Finalizer added in v0.8.0

type Finalizer interface {
	AddFinalizer(ctx context.Context, obj Object) error
	RemoveFinalizer(ctx context.Context, obj Object) error
}

A Finalizer manages the finalizers on the resource.

type FinalizerFns added in v0.8.0

type FinalizerFns struct {
	AddFinalizerFn    func(ctx context.Context, obj Object) error
	RemoveFinalizerFn func(ctx context.Context, obj Object) error
}

A FinalizerFns satisfy the Finalizer interface.

func (FinalizerFns) AddFinalizer added in v0.8.0

func (f FinalizerFns) AddFinalizer(ctx context.Context, obj Object) error

AddFinalizer to the supplied resource.

func (FinalizerFns) RemoveFinalizer added in v0.8.0

func (f FinalizerFns) RemoveFinalizer(ctx context.Context, obj Object) error

RemoveFinalizer from the supplied resource.

type LocalConnectionSecretOwner

type LocalConnectionSecretOwner interface {
	runtime.Object
	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 ManagedConnectionPropagator

type ManagedConnectionPropagator interface {
	PropagateConnection(ctx context.Context, o LocalConnectionSecretOwner, 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, o LocalConnectionSecretOwner, mg Managed) error

A ManagedConnectionPropagatorFn is a function that satisfies the ManagedConnectionPropagator interface.

func (ManagedConnectionPropagatorFn) PropagateConnection

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

type ManagedKind

type ManagedKind schema.GroupVersionKind

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

type ManagedList added in v0.8.0

type ManagedList interface {
	runtime.Object

	// GetItems returns the list of managed resources.
	GetItems() []Managed
}

A ManagedList is a list of managed resources.

type ManagedResourceReferencer

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

A ManagedResourceReferencer may reference a concrete managed resource.

type Object

type Object interface {
	metav1.Object
	runtime.Object
}

An Object is a Kubernetes object.

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 Provider

type Provider interface {
	Object

	CredentialsSecretReferencer
}

A Provider is a Kubernetes object that refers to credentials to connect to an external system.

type ProviderReferencer

type ProviderReferencer interface {
	GetProviderReference() *corev1.ObjectReference
	SetProviderReference(p *corev1.ObjectReference)
}

A ProviderReferencer may reference a provider resource.

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 ReferenceStatusType = iota
	ReferenceNotFound
	ReferenceNotReady
	ReferenceReady
)

Reference statuses.

func (ReferenceStatusType) String

func (t ReferenceStatusType) String() string

type Requirement added in v0.8.0

A Requirement for a Composite resource.

type RequirementKind added in v0.8.0

type RequirementKind schema.GroupVersionKind

A RequirementKind contains the type metadata for a kind of requirement resource.

type RequirementReferencer added in v0.8.0

type RequirementReferencer interface {
	SetRequirementReference(r *corev1.ObjectReference)
	GetRequirementReference() *corev1.ObjectReference
}

A RequirementReferencer can reference a requirement resource.

type Target

A Target is a Kubernetes object that refers to credentials to connect to a deployment target. Target is a subset of the Claim interface.

type TargetKind

type TargetKind schema.GroupVersionKind

A TargetKind contains the type metadata for a kind of target resource.

Directories

Path Synopsis
Package fake provides fake Crossplane resources for use in tests.
Package fake provides fake Crossplane resources for use in tests.
Package unstructured contains utilities unstructured Kubernetes objects.
Package unstructured contains utilities unstructured Kubernetes objects.
composed
Package composed contains an unstructured composed resource.
Package composed contains an unstructured composed resource.
composite
Package composite contains an unstructured composite resource.
Package composite contains an unstructured composite resource.
requirement
Package requirement contains an unstructured resource requirement.
Package requirement contains an unstructured resource requirement.

Jump to

Keyboard shortcuts

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