Documentation ¶
Index ¶
- Constants
- func ControllerName(name string) string
- func GetCompositionResourceName(o metav1.Object) string
- func IsReady(_ context.Context, cd resource.Composed, t v1.ComposedTemplate) (bool, error)
- func RejectDuplicateNames(comp *v1.Composition) error
- func RejectMixedTemplates(comp *v1.Composition) error
- func RenderComposite(_ context.Context, cp resource.Composite, cd resource.Composed, ...) error
- func SetCompositionResourceName(o metav1.Object, name string)
- type APIConfigurator
- type APIConnectionDetailsFetcher
- type APIDefaultCompositionSelector
- type APIDryRunRenderer
- type APIFilteredSecretPublisher
- type APILabelSelectorResolver
- type APINamingConfigurator
- type CompositionSelector
- type CompositionSelectorChain
- type CompositionSelectorFn
- type CompositionTemplateAssociator
- type CompositionTemplateAssociatorFn
- type CompositionValidator
- type CompositionValidatorFn
- type Configurator
- type ConfiguratorChain
- type ConfiguratorFn
- type ConnectionDetailsFetcher
- type ConnectionDetailsFetcherFn
- type ConnectionPublisher
- type ConnectionPublisherFn
- type ConnectionSecretFilterer
- type EnforcedCompositionSelector
- type GarbageCollectingAssociator
- type Observation
- type ReadinessChecker
- type ReadinessCheckerFn
- type Reconciler
- type ReconcilerOption
- func WithClientApplicator(ca resource.ClientApplicator) ReconcilerOption
- func WithCompositeRenderer(rd Renderer) ReconcilerOption
- func WithCompositionSelector(p CompositionSelector) ReconcilerOption
- func WithCompositionTemplateAssociator(a CompositionTemplateAssociator) ReconcilerOption
- func WithCompositionValidator(v CompositionValidator) ReconcilerOption
- func WithConfigurator(c Configurator) ReconcilerOption
- func WithConnectionDetailsFetcher(f ConnectionDetailsFetcher) ReconcilerOption
- func WithConnectionPublisher(p ConnectionPublisher) ReconcilerOption
- func WithLogger(log logging.Logger) ReconcilerOption
- func WithReadinessChecker(c ReadinessChecker) ReconcilerOption
- func WithRecorder(er event.Recorder) ReconcilerOption
- func WithRenderer(rd Renderer) ReconcilerOption
- type RenderFn
- type Renderer
- type RendererFn
- type TemplateAssociation
- type ValidationChain
Constants ¶
const (
AnnotationKeyCompositionResourceName = "crossplane.io/composition-resource-name"
)
Annotation keys.
Variables ¶
This section is empty.
Functions ¶
func ControllerName ¶
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
GetCompositionResourceName gets the name of the composition template used to reconcile a composed resource from its annotations.
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
func RenderComposite(_ context.Context, cp resource.Composite, cd resource.Composed, t v1.ComposedTemplate) error
RenderComposite renders the supplied composite resource using the supplied composed resource and template.
func SetCompositionResourceName ¶ added in v1.1.0
SetCompositionResourceName sets the name of the composition template used to reconcile a composed resource as an annotation.
Types ¶
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 ¶
func (cdf *APIConnectionDetailsFetcher) FetchConnectionDetails(ctx context.Context, cd resource.Composed, t v1.ComposedTemplate) (managed.ConnectionDetails, error)
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 ¶
func (r *APIDryRunRenderer) Render(ctx context.Context, cp resource.Composite, cd resource.Composed, t v1.ComposedTemplate) error
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 ¶
func (a *APIFilteredSecretPublisher) PublishConnection(ctx context.Context, o resource.ConnectionSecretOwner, c managed.ConnectionDetails) (bool, error)
PublishConnection publishes the supplied ConnectionDetails to the Secret referenced in the resource.
func (*APIFilteredSecretPublisher) UnpublishConnection ¶
func (a *APIFilteredSecretPublisher) UnpublishConnection(_ context.Context, _ resource.ConnectionSecretOwner, _ managed.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 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 ¶
func (c *APINamingConfigurator) Configure(ctx context.Context, cp resource.Composite, _ *v1.Composition) error
Configure the supplied composite resource's root name prefix.
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 ¶
A CompositionSelectorFn selects a composition reference.
func (CompositionSelectorFn) SelectComposition ¶
SelectComposition for the supplied composite resource.
type CompositionTemplateAssociator ¶ added in v1.1.0
type CompositionTemplateAssociator interface {
AssociateTemplates(context.Context, resource.Composite, *v1.Composition) ([]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.Composition) ([]TemplateAssociation, error)
A CompositionTemplateAssociatorFn returns an array of template associations.
func (CompositionTemplateAssociatorFn) AssociateTemplates ¶ added in v1.1.0
func (fn CompositionTemplateAssociatorFn) AssociateTemplates(ctx context.Context, cr resource.Composite, comp *v1.Composition) ([]TemplateAssociation, error)
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 ¶
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 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 ¶
func (f ConnectionDetailsFetcherFn) FetchConnectionDetails(ctx context.Context, cd resource.Composed, t v1.ComposedTemplate) (managed.ConnectionDetails, error)
FetchConnectionDetails calls the FetchConnectionDetailsFn.
type ConnectionPublisher ¶
type ConnectionPublisher interface { // PublishConnection details for the supplied resource. Publishing must be // additive; i.e. if details (a, b, c) are published, subsequently // publishing details (b, c, d) should update (b, c) but not remove a. // Returns 'published' if the publish was not a no-op. PublishConnection(ctx context.Context, o resource.ConnectionSecretOwner, c managed.ConnectionDetails) (published bool, err error) }
A ConnectionPublisher publishes the supplied ConnectionDetails for the supplied resource. Publishers must handle the case in which the supplied ConnectionDetails are empty.
type ConnectionPublisherFn ¶
type ConnectionPublisherFn func(ctx context.Context, o resource.ConnectionSecretOwner, c managed.ConnectionDetails) (published bool, err error)
A ConnectionPublisherFn publishes the supplied ConnectionDetails for the supplied resource.
func (ConnectionPublisherFn) PublishConnection ¶
func (fn ConnectionPublisherFn) PublishConnection(ctx context.Context, o resource.ConnectionSecretOwner, c managed.ConnectionDetails) (published bool, err error)
PublishConnection details for the supplied resource.
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
func (a *GarbageCollectingAssociator) AssociateTemplates(ctx context.Context, cr resource.Composite, comp *v1.Composition) ([]TemplateAssociation, error)
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.
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.
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 WithCompositeRenderer ¶ added in v1.1.0
func WithCompositeRenderer(rd Renderer) ReconcilerOption
WithCompositeRenderer specifies how the Reconciler should render composite resources.
func WithCompositionSelector ¶
func WithCompositionSelector(p 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 WithConnectionPublisher ¶
func WithConnectionPublisher(p ConnectionPublisher) ReconcilerOption
WithConnectionPublisher 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 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 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.
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.