resource

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 resource provides types and functions that can be used to build Kubernetes controllers that reconcile Crossplane resources.

Index

Constants

View Source
const (
	AnnotationKeyPropagateToPrefix = "to.propagate.crossplane.io"

	AnnotationKeyPropagateFromNamespace = "from.propagate.crossplane.io/namespace"
	AnnotationKeyPropagateFromName      = "from.propagate.crossplane.io/name"
	AnnotationKeyPropagateFromUID       = "from.propagate.crossplane.io/uid"

	AnnotationDelimiter = "/"
)

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.

Variables

This section is empty.

Functions

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

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

PropagateConnection details from the supplied resource to the supplied claim.

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

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

A ClaimReferencer may reference a resource claim.

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

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

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

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

func (*EnqueueRequestForPropagated) Delete added in v0.4.0

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

func (*EnqueueRequestForPropagated) Generic added in v0.4.0

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

func (*EnqueueRequestForPropagated) Update added in v0.4.0

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

type ManagedResourceReferencer

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

A ManagedResourceReferencer may reference a concrete managed resource.

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

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

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

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

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.

Jump to

Keyboard shortcuts

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