composite

package
v1.10.2 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2023 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AnnotationKeyCompositionResourceName = "crossplane.io/composition-resource-name"
)

Annotation keys.

Variables

This section is empty.

Functions

func AsComposition added in v1.4.0

func AsComposition(cr *v1alpha1.CompositionRevision) *v1.Composition

AsComposition creates a new composition from the supplied revision. It exists only as a temporary translation layer to allow us to introduce the alpha CompositionRevision type with minimal changes to the XR reconciler. Once CompositionRevision leaves alpha this code should be removed and the XR reconciler should operate on CompositionRevisions instead.

func AsCompositionComposedTemplate added in v1.4.0

func AsCompositionComposedTemplate(rct v1alpha1.ComposedTemplate) v1.ComposedTemplate

AsCompositionComposedTemplate translates a composition revision's composed (resource) template to a composition composed template.

func AsCompositionConnectionDetail added in v1.4.0

func AsCompositionConnectionDetail(rcd v1alpha1.ConnectionDetail) v1.ConnectionDetail

AsCompositionConnectionDetail translates a composition revision's connection detail to a composition connection detail.

func AsCompositionPatch added in v1.4.0

func AsCompositionPatch(rp v1alpha1.Patch) v1.Patch

AsCompositionPatch translates a composition revision's patch to a composition patch.

func AsCompositionPatchSet added in v1.4.0

func AsCompositionPatchSet(rps v1alpha1.PatchSet) v1.PatchSet

AsCompositionPatchSet translates a composition revision's patch set to a composition patch set.

func AsCompositionReadinessCheck added in v1.4.0

func AsCompositionReadinessCheck(rrc v1alpha1.ReadinessCheck) v1.ReadinessCheck

AsCompositionReadinessCheck translates a composition revision's readiness check to a composition readiness check.

func AsCompositionSpec added in v1.4.0

func AsCompositionSpec(crs v1alpha1.CompositionRevisionSpec) v1.CompositionSpec

AsCompositionSpec translates a composition revision's spec to a composition spec.

func AsCompositionTransform added in v1.4.0

func AsCompositionTransform(rt v1alpha1.Transform) v1.Transform

AsCompositionTransform translates a compostion revision's transform to a composition transform.

func ControllerName

func ControllerName(name string) string

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

func GetCompositionResourceName added in v1.1.0

func GetCompositionResourceName(o metav1.Object) string

GetCompositionResourceName gets the name of the composition template used to reconcile a composed resource from its annotations.

func IsReady

IsReady returns whether the composed resource is ready.

func RejectDuplicateNames added in v1.1.0

func RejectDuplicateNames(comp *v1.Composition) error

RejectDuplicateNames validates that all template names are unique within the supplied Composition.

func RejectMixedTemplates added in v1.1.0

func RejectMixedTemplates(comp *v1.Composition) error

RejectMixedTemplates validates that the supplied Composition does not attempt to mix named and anonymous templates. If some but not all templates are named it's safest to refuse to operate. We don't have enough information to use the named composer, but using the anonymous composer may be surprising. There's a risk that someone added a new anonymous template to a Composition that otherwise uses named templates. If they added the new template to the beginning or middle of the resources array using the anonymous composer would be destructive, because it assumes template N always corresponds to existing template N.

func RenderComposite added in v1.1.0

RenderComposite renders the supplied composite resource using the supplied composed resource and template.

func SetCompositionResourceName added in v1.1.0

func SetCompositionResourceName(o metav1.Object, name string)

SetCompositionResourceName sets the name of the composition template used to reconcile a composed resource as an annotation.

Types

type APICompositionFetcher added in v1.4.0

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

An APICompositionFetcher fetches the Composition referenced by a composite resource.

func NewAPICompositionFetcher added in v1.4.0

func NewAPICompositionFetcher(r client.Reader) *APICompositionFetcher

NewAPICompositionFetcher returns a CompositionFetcher that fetches the Composition referenced by a composite resource.

func (*APICompositionFetcher) Fetch added in v1.4.0

Fetch the Composition referenced by the supplied composite resource. Panics if the composite resource's composition reference is nil.

type APIConfigurator

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

An APIConfigurator configures a composite resource using its composition.

func NewAPIConfigurator

func NewAPIConfigurator(c client.Client) *APIConfigurator

NewAPIConfigurator returns a Configurator that configures a composite resource using its composition.

func (*APIConfigurator) Configure

func (c *APIConfigurator) Configure(ctx context.Context, cp resource.Composite, comp *v1.Composition) error

Configure any required fields that were omitted from the composite resource by copying them from its composition.

type APIConnectionDetailsFetcher

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

An APIConnectionDetailsFetcher may use the API server to read connection details from a Secret.

func NewAPIConnectionDetailsFetcher

func NewAPIConnectionDetailsFetcher(c client.Client) *APIConnectionDetailsFetcher

NewAPIConnectionDetailsFetcher returns a ConnectionDetailsFetcher that may use the API server to read connection details from a Secret.

func (*APIConnectionDetailsFetcher) FetchConnectionDetails

FetchConnectionDetails of the supplied composed resource, if any.

type APIDefaultCompositionSelector

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

APIDefaultCompositionSelector selects the default composition referenced in the definition of the resource if neither a reference nor selector is given in composite resource.

func NewAPIDefaultCompositionSelector

func NewAPIDefaultCompositionSelector(c client.Client, ref corev1.ObjectReference, r event.Recorder) *APIDefaultCompositionSelector

NewAPIDefaultCompositionSelector returns a APIDefaultCompositionSelector.

func (*APIDefaultCompositionSelector) SelectComposition

func (s *APIDefaultCompositionSelector) SelectComposition(ctx context.Context, cp resource.Composite) error

SelectComposition selects the default compositionif neither a reference nor selector is given in composite resource.

type APIDryRunRenderer

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

An APIDryRunRenderer renders composed resources. It may perform a dry-run create against an API server in order to name and validate the rendered resource.

func NewAPIDryRunRenderer

func NewAPIDryRunRenderer(c client.Client) *APIDryRunRenderer

NewAPIDryRunRenderer returns a Renderer of composed resources that may perform a dry-run create against an API server in order to name and validate it.

func (*APIDryRunRenderer) Render

Render the supplied composed resource using the supplied composite resource and template. The rendered resource may be submitted to an API server via a dry run create in order to name and validate it.

type APIFilteredSecretPublisher

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

APIFilteredSecretPublisher publishes ConnectionDetails content after filtering it through a set of permitted keys.

func NewAPIFilteredSecretPublisher

func NewAPIFilteredSecretPublisher(c client.Client, filter []string) *APIFilteredSecretPublisher

NewAPIFilteredSecretPublisher returns a ConnectionPublisher that only publishes connection secret keys that are included in the supplied filter.

func (*APIFilteredSecretPublisher) PublishConnection

PublishConnection publishes the supplied ConnectionDetails to the Secret referenced in the resource.

func (*APIFilteredSecretPublisher) UnpublishConnection

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

type APILabelSelectorResolver

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

APILabelSelectorResolver is used to resolve the composition selector on the instance to composition reference.

func NewAPILabelSelectorResolver

func NewAPILabelSelectorResolver(c client.Client) *APILabelSelectorResolver

NewAPILabelSelectorResolver returns a SelectorResolver for composite resource.

func (*APILabelSelectorResolver) SelectComposition

func (r *APILabelSelectorResolver) SelectComposition(ctx context.Context, cp resource.Composite) error

SelectComposition resolves selector to a reference if it doesn't exist.

type APINamingConfigurator

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

An APINamingConfigurator sets the root name prefix to its own name if it is not already set.

func NewAPINamingConfigurator

func NewAPINamingConfigurator(c client.Client) *APINamingConfigurator

NewAPINamingConfigurator returns a Configurator that sets the root name prefixKu to its own name if it is not already set.

func (*APINamingConfigurator) Configure

Configure the supplied composite resource's root name prefix.

type APIRevisionFetcher added in v1.4.0

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

An APIRevisionFetcher selects the appropriate CompositionRevision for a composite resource, fetches it, and returns it as a Composition. This is done for compatibility with existing Composition logic while CompositionRevisions are in alpha.

func NewAPIRevisionFetcher added in v1.4.0

func NewAPIRevisionFetcher(ca resource.ClientApplicator) *APIRevisionFetcher

NewAPIRevisionFetcher returns a RevisionFetcher that fetches the Revision referenced by a composite resource.

func (*APIRevisionFetcher) Fetch added in v1.4.0

Fetch the appropriate CompositionRevision for the supplied composite resource and convert it to a Composition. Panics if the composite resource's composition reference is nil, but handles setting the composition revision reference.

type CompositionFetcher added in v1.4.0

type CompositionFetcher interface {
	Fetch(ctx context.Context, cr resource.Composite) (*v1.Composition, error)
}

A CompositionFetcher fetches an appropriate Composition for the supplied composite resource.

type CompositionFetcherFn added in v1.4.0

type CompositionFetcherFn func(ctx context.Context, cr resource.Composite) (*v1.Composition, error)

A CompositionFetcherFn fetches an appropriate Composition for the supplied composite resource.

func (CompositionFetcherFn) Fetch added in v1.4.0

Fetch an appropriate Composition for the supplied Composite resource.

type CompositionSelector

type CompositionSelector interface {
	SelectComposition(ctx context.Context, cr resource.Composite) error
}

A CompositionSelector selects a composition reference.

type CompositionSelectorChain

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

CompositionSelectorChain calls the given list of CompositionSelectors in order.

func NewCompositionSelectorChain

func NewCompositionSelectorChain(list ...CompositionSelector) *CompositionSelectorChain

NewCompositionSelectorChain returns a new CompositionSelectorChain.

func (*CompositionSelectorChain) SelectComposition

func (r *CompositionSelectorChain) SelectComposition(ctx context.Context, cp resource.Composite) error

SelectComposition calls all SelectComposition functions of CompositionSelectors in the list.

type CompositionSelectorFn

type CompositionSelectorFn func(ctx context.Context, cr resource.Composite) error

A CompositionSelectorFn selects a composition reference.

func (CompositionSelectorFn) SelectComposition

func (fn CompositionSelectorFn) SelectComposition(ctx context.Context, cr resource.Composite) error

SelectComposition for the supplied composite resource.

type CompositionTemplateAssociator added in v1.1.0

type CompositionTemplateAssociator interface {
	AssociateTemplates(context.Context, resource.Composite, []v1.ComposedTemplate) ([]TemplateAssociation, error)
}

A CompositionTemplateAssociator returns an array of template associations.

type CompositionTemplateAssociatorFn added in v1.1.0

type CompositionTemplateAssociatorFn func(context.Context, resource.Composite, []v1.ComposedTemplate) ([]TemplateAssociation, error)

A CompositionTemplateAssociatorFn returns an array of template associations.

func (CompositionTemplateAssociatorFn) AssociateTemplates added in v1.1.0

AssociateTemplates with composed resources.

type CompositionValidator added in v1.1.0

type CompositionValidator interface {
	Validate(comp *v1.Composition) error
}

A CompositionValidator validates the supplied Composition.

type CompositionValidatorFn added in v1.1.0

type CompositionValidatorFn func(comp *v1.Composition) error

A CompositionValidatorFn validates the supplied Composition.

func (CompositionValidatorFn) Validate added in v1.1.0

func (fn CompositionValidatorFn) Validate(comp *v1.Composition) error

Validate the supplied Composition.

type Configurator

type Configurator interface {
	Configure(ctx context.Context, cr resource.Composite, cp *v1.Composition) error
}

A Configurator configures a composite resource using its composition.

type ConfiguratorChain

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

ConfiguratorChain executes the Configurators in given order.

func NewConfiguratorChain

func NewConfiguratorChain(l ...Configurator) *ConfiguratorChain

NewConfiguratorChain returns a new *ConfiguratorChain.

func (*ConfiguratorChain) Configure

func (cc *ConfiguratorChain) Configure(ctx context.Context, cp resource.Composite, comp *v1.Composition) error

Configure calls Configure function of every Configurator in the list.

type ConfiguratorFn

type ConfiguratorFn func(ctx context.Context, cr resource.Composite, cp *v1.Composition) error

A ConfiguratorFn configures a composite resource using its composition.

func (ConfiguratorFn) Configure

func (fn ConfiguratorFn) Configure(ctx context.Context, cr resource.Composite, cp *v1.Composition) error

Configure the supplied composite resource using its composition.

type ConnectionDetailsFetcher

type ConnectionDetailsFetcher interface {
	FetchConnectionDetails(ctx context.Context, cd resource.Composed, t v1.ComposedTemplate) (managed.ConnectionDetails, error)
}

ConnectionDetailsFetcher fetches the connection details of the Composed resource.

type ConnectionDetailsFetcherChain added in v1.7.0

type ConnectionDetailsFetcherChain []ConnectionDetailsFetcher

A ConnectionDetailsFetcherChain chains multiple ConnectionDetailsFetchers.

func (ConnectionDetailsFetcherChain) FetchConnectionDetails added in v1.7.0

FetchConnectionDetails of the supplied composed resource, if any.

type ConnectionDetailsFetcherFn

type ConnectionDetailsFetcherFn func(ctx context.Context, cd resource.Composed, t v1.ComposedTemplate) (managed.ConnectionDetails, error)

A ConnectionDetailsFetcherFn fetches the connection details of the supplied composed resource, if any.

func (ConnectionDetailsFetcherFn) FetchConnectionDetails

FetchConnectionDetails calls the FetchConnectionDetailsFn.

type ConnectionSecretFilterer

type ConnectionSecretFilterer interface {
	GetConnectionSecretKeys() []string
}

ConnectionSecretFilterer returns a set of allowed keys.

type EnforcedCompositionSelector

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

EnforcedCompositionSelector , if it's given, selects the enforced composition on the definition for all composite instances.

func NewEnforcedCompositionSelector

func NewEnforcedCompositionSelector(def v1.CompositeResourceDefinition, r event.Recorder) *EnforcedCompositionSelector

NewEnforcedCompositionSelector returns a EnforcedCompositionSelector.

func (*EnforcedCompositionSelector) SelectComposition

func (s *EnforcedCompositionSelector) SelectComposition(_ context.Context, cp resource.Composite) error

SelectComposition selects the enforced composition if it's given in definition.

type GarbageCollectingAssociator added in v1.1.0

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

A GarbageCollectingAssociator associates a Composition's resource templates with (references to) composed resources. It tries to associate them by checking the template name annotation of each referenced resource. If any template or existing composed resource can't be associated by name it falls back to associating them by order. If it encounters a referenced resource that corresponds to a non-existent template the resource will be garbage collected (i.e. deleted).

func NewGarbageCollectingAssociator added in v1.1.0

func NewGarbageCollectingAssociator(c client.Client) *GarbageCollectingAssociator

NewGarbageCollectingAssociator returns a CompositionTemplateAssociator that may garbage collect composed resources.

func (*GarbageCollectingAssociator) AssociateTemplates added in v1.1.0

AssociateTemplates with composed resources.

type Observation

type Observation struct {
	Ref               corev1.ObjectReference
	ConnectionDetails managed.ConnectionDetails
	Ready             bool
}

Observation is the result of composed reconciliation.

type ReadinessChecker

type ReadinessChecker interface {
	IsReady(ctx context.Context, cd resource.Composed, t v1.ComposedTemplate) (ready bool, err error)
}

A ReadinessChecker checks whether a composed resource is ready or not.

type ReadinessCheckerFn

type ReadinessCheckerFn func(ctx context.Context, cd resource.Composed, t v1.ComposedTemplate) (ready bool, err error)

A ReadinessCheckerFn checks whether a composed resource is ready or not.

func (ReadinessCheckerFn) IsReady

func (fn ReadinessCheckerFn) IsReady(ctx context.Context, cd resource.Composed, t v1.ComposedTemplate) (ready bool, err error)

IsReady reports whether a composed resource is ready or not.

type Reconciler

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

A Reconciler reconciles composite resources.

func NewReconciler

func NewReconciler(mgr manager.Manager, of resource.CompositeKind, opts ...ReconcilerOption) *Reconciler

NewReconciler returns a new Reconciler of composite resources.

func (*Reconciler) Reconcile

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

Reconcile a composite resource.

type ReconcilerOption

type ReconcilerOption func(*Reconciler)

ReconcilerOption is used to configure the Reconciler.

func WithClientApplicator

func WithClientApplicator(ca resource.ClientApplicator) ReconcilerOption

WithClientApplicator specifies how the Reconciler should interact with the Kubernetes API.

func WithCompositeFinalizer added in v1.7.0

func WithCompositeFinalizer(f resource.Finalizer) ReconcilerOption

WithCompositeFinalizer specifies how the composition to be used should be selected. WithCompositeFinalizer specifies which Finalizer should be used to finalize composites when they are deleted.

func WithCompositeRenderer added in v1.1.0

func WithCompositeRenderer(rd Renderer) ReconcilerOption

WithCompositeRenderer specifies how the Reconciler should render composite resources.

func WithCompositionFetcher added in v1.4.0

func WithCompositionFetcher(f CompositionFetcher) ReconcilerOption

WithCompositionFetcher specifies how the composition to be used should be fetched.

func WithCompositionSelector

func WithCompositionSelector(s CompositionSelector) ReconcilerOption

WithCompositionSelector specifies how the composition to be used should be selected.

func WithCompositionTemplateAssociator added in v1.1.0

func WithCompositionTemplateAssociator(a CompositionTemplateAssociator) ReconcilerOption

WithCompositionTemplateAssociator specifies how the Reconciler should associate composition templates with composed resources.

func WithCompositionValidator added in v1.1.0

func WithCompositionValidator(v CompositionValidator) ReconcilerOption

WithCompositionValidator specifies how the Reconciler should validate Compositions.

func WithConfigurator

func WithConfigurator(c Configurator) ReconcilerOption

WithConfigurator specifies how the Reconciler should configure composite resources using their composition.

func WithConnectionDetailsFetcher

func WithConnectionDetailsFetcher(f ConnectionDetailsFetcher) ReconcilerOption

WithConnectionDetailsFetcher specifies how the Reconciler should fetch the connection details of composed resources.

func WithConnectionPublishers added in v1.7.0

func WithConnectionPublishers(p ...managed.ConnectionPublisher) ReconcilerOption

WithConnectionPublishers specifies how the Reconciler should publish connection secrets.

func WithLogger

func WithLogger(log logging.Logger) ReconcilerOption

WithLogger specifies how the Reconciler should log messages.

func WithPollInterval added in v1.6.0

func WithPollInterval(after time.Duration) ReconcilerOption

WithPollInterval specifies how long the Reconciler should wait before queueing a new reconciliation after a successful reconcile. The Reconciler requeues after a specified duration when it is not actively waiting for an external operation, but wishes to check whether resources it does not have a watch on (i.e. composed resources) need to be reconciled.

func WithReadinessChecker

func WithReadinessChecker(c ReadinessChecker) ReconcilerOption

WithReadinessChecker specifies how the Reconciler should fetch the connection details of composed resources.

func WithRecorder

func WithRecorder(er event.Recorder) ReconcilerOption

WithRecorder specifies how the Reconciler should record Kubernetes events.

func WithRenderer

func WithRenderer(rd Renderer) ReconcilerOption

WithRenderer specifies how the Reconciler should render composed resources.

type RenderFn

type RenderFn func(cp resource.Composite, cd resource.Composed, t v1.ComposedTemplate) error

A RenderFn renders the supplied composed resource.

func (RenderFn) Render

Render calls RenderFn.

type Renderer

type Renderer interface {
	Render(ctx context.Context, cp resource.Composite, cd resource.Composed, t v1.ComposedTemplate) error
}

A Renderer is used to render a composed resource.

type RendererFn

type RendererFn func(ctx context.Context, cp resource.Composite, cd resource.Composed, t v1.ComposedTemplate) error

A RendererFn may be used to render a composed resource.

func (RendererFn) Render

Render the supplied composed resource using the supplied composite resource and template as inputs.

type SecretStoreConnectionDetailsConfigurator added in v1.7.0

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

A SecretStoreConnectionDetailsConfigurator configures a composite resource using its composition.

func NewSecretStoreConnectionDetailsConfigurator added in v1.7.0

func NewSecretStoreConnectionDetailsConfigurator(c client.Client) *SecretStoreConnectionDetailsConfigurator

NewSecretStoreConnectionDetailsConfigurator returns a Configurator that configures a composite resource using its composition.

func (*SecretStoreConnectionDetailsConfigurator) Configure added in v1.7.0

Configure any required fields that were omitted from the composite resource by copying them from its composition.

type SecretStoreConnectionDetailsFetcher added in v1.7.0

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

SecretStoreConnectionDetailsFetcher is a ConnectionDetailsFetcher that fetches connection details to the configured SecretStore.

func NewSecretStoreConnectionDetailsFetcher added in v1.7.0

func NewSecretStoreConnectionDetailsFetcher(f managed.ConnectionDetailsFetcher) *SecretStoreConnectionDetailsFetcher

NewSecretStoreConnectionDetailsFetcher returns a SecretStoreConnectionDetailsFetcher

func (*SecretStoreConnectionDetailsFetcher) FetchConnectionDetails added in v1.7.0

FetchConnectionDetails of the supplied composed resource, if any.

type SecretStoreConnectionPublisher added in v1.7.0

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

SecretStoreConnectionPublisher is a ConnectionPublisher that stores connection details on the configured SecretStore.

func NewSecretStoreConnectionPublisher added in v1.7.0

func NewSecretStoreConnectionPublisher(p managed.ConnectionPublisher, filter []string) *SecretStoreConnectionPublisher

NewSecretStoreConnectionPublisher returns a SecretStoreConnectionPublisher

func (*SecretStoreConnectionPublisher) PublishConnection added in v1.7.0

PublishConnection details for the supplied resource.

func (*SecretStoreConnectionPublisher) UnpublishConnection added in v1.7.0

UnpublishConnection details for the supplied resource.

type TemplateAssociation added in v1.1.0

type TemplateAssociation struct {
	Template  v1.ComposedTemplate
	Reference corev1.ObjectReference
}

A TemplateAssociation associates a composed resource template with a composed resource. If no such resource exists the reference will be empty.

func AssociateByOrder added in v1.1.0

func AssociateByOrder(t []v1.ComposedTemplate, r []corev1.ObjectReference) []TemplateAssociation

AssociateByOrder associates the supplied templates with the supplied resource references by order; i.e. by assuming template n corresponds to reference n. The returned array will always be of the same length as the supplied array of templates. Any additional references will be truncated.

type ValidationChain added in v1.1.0

type ValidationChain []CompositionValidator

A ValidationChain runs multiple validations.

func (ValidationChain) Validate added in v1.1.0

func (vs ValidationChain) Validate(comp *v1.Composition) error

Validate the supplied Composition.

Jump to

Keyboard shortcuts

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