managed

package
v0.3.77 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ControllerName added in v0.3.65

func ControllerName(kind string) string

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

Types

type APISimpleReferenceResolver

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

An APISimpleReferenceResolver resolves references from one managed resource to others by calling the referencing resource's ResolveReferences method, if any.

func NewAPISimpleReferenceResolver

func NewAPISimpleReferenceResolver(c client.Client) *APISimpleReferenceResolver

NewAPISimpleReferenceResolver returns a ReferenceResolver that resolves references from one managed resource to others by calling the referencing resource's ResolveReferences method, if any.

func (*APISimpleReferenceResolver) ResolveReferences

func (a *APISimpleReferenceResolver) ResolveReferences(ctx context.Context, mg resource.Managed) error

ResolveReferences of the supplied managed resource by calling its ResolveReferences method, 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 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 resource.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 resource.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 resource.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 resource.Managed) error

	// GetTarget returns the targets the resource is assigned assigned to
	GetTarget() []string

	// GetConfig returns the full configuration of the network node
	GetConfig(ctx context.Context) ([]byte, 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 resource.Managed) (ExternalObservation, error)
	CreateFn    func(ctx context.Context, mg resource.Managed) (ExternalCreation, error)
	UpdateFn    func(ctx context.Context, mg resource.Managed) (ExternalUpdate, error)
	DeleteFn    func(ctx context.Context, mg resource.Managed) error
	GetTargetFn func() []string
	GetConfigFn func(ctx context.Context) ([]byte, 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

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

func (ExternalClientFns) GetConfig added in v0.4.15

func (e ExternalClientFns) GetConfig(ctx context.Context) ([]byte, error)

GetConfig returns the full configuration of the network node

func (ExternalClientFns) GetTarget added in v0.4.15

func (e ExternalClientFns) GetTarget() []string

GetTarget return the real target for the external 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 resource.Managed) (ExternalClient, error)
}

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

type ExternalConnectorFn

type ExternalConnectorFn func(ctx context.Context, mg resource.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 {
	// ExternalNameAssigned is true if the Create operation resulted in a change
	// in the external name annotation. If that's the case, we need to issue a
	// spec update and make sure it goes through so that we don't lose the identifier
	// of the resource we just created.
	ExternalNameAssigned bool

	// ConnectionDetails required to connect to this resource. These details
	// are a set that is collated throughout the managed resource's lifecycle -
	// i.e. returning new connection details will have no affect on old details
	// unless an existing key is overwritten. Crossplane may publish these
	// credentials to a store (e.g. a Secret).
	ConnectionDetails ConnectionDetails
}

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

type ExternalObservation

type ExternalObservation struct {
	// ResourceExists must be true if a corresponding external resource exists
	// for the managed resource. Typically this is proven by the presence of an
	// external resource of the expected kind whose unique identifier matches
	// the managed resource's external name. Crossplane uses this information to
	// determine whether it needs to create or delete the external resource.
	ResourceExists bool

	// ResourceUpToDate should be true if the corresponding external resource
	// appears to be up-to-date - i.e. updating the external resource to match
	// the desired state of the managed resource would be a no-op. Keep in mind
	// that often only a subset of external resource fields can be updated.
	// Crossplane uses this information to determine whether it needs to update
	// the external resource.
	ResourceUpToDate bool

	// ResourceLateInitialized should be true if the managed resource's spec was
	// updated during its observation. A Crossplane provider may update a
	// managed resource's spec fields after it is created or updated, as long as
	// the updates are limited to setting previously unset fields, and adding
	// keys to maps. Crossplane uses this information to determine whether
	// changes to the spec were made during observation that must be persisted.
	// Note that changes to the spec will be persisted before changes to the
	// status, and that pending changes to the status may be lost when the spec
	// is persisted. Status changes will be persisted by the first subsequent
	// observation that _does not_ late initialize the managed resource, so it
	// is important that Observe implementations do not late initialize the
	// resource every time they are called.
	ResourceLateInitialized bool

	// ConnectionDetails required to connect to this resource. These details
	// are a set that is collated throughout the managed resource's lifecycle -
	// i.e. returning new connection details will have no affect on old details
	// unless an existing key is overwritten. Crossplane may publish these
	// credentials to a store (e.g. a Secret).
	ConnectionDetails ConnectionDetails
}

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

type ExternalUpdate

type ExternalUpdate struct {
}

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

type Initializer

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

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

type InitializerChain

type InitializerChain []Initializer

A InitializerChain chains multiple managed initializers.

func (InitializerChain) Initialize

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

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

type InitializerFn

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

A InitializerFn is a function that satisfies the Initializer interface.

func (InitializerFn) Initialize

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

Initialize calls InitializerFn function.

type NameAsExternalName

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

NameAsExternalName 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 Target.

func NewNameAsExternalName

func NewNameAsExternalName(c client.Client) *NameAsExternalName

NewNameAsExternalName returns a new NameAsExternalName.

func (*NameAsExternalName) Initialize

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

Initialize the given managed resource.

type NopClient

type NopClient struct{}

A NopClient does nothing.

func (*NopClient) Create

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

func (*NopClient) Delete

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

Delete does nothing. It never returns an error.

func (*NopClient) GetConfig added in v0.4.15

func (c *NopClient) GetConfig(ctx context.Context) ([]byte, error)

GetConfig returns the full configuration of the network node

func (*NopClient) GetTarget added in v0.3.76

func (c *NopClient) GetTarget() []string

GetTarget return on empty string list

func (*NopClient) Observe

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

func (*NopClient) Update

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

type NopValidator struct{}

func (*NopValidator) ValidateExternalleafRef added in v0.4.15

func (e *NopValidator) ValidateExternalleafRef(ctx context.Context, mg resource.Managed, cfg []byte) (ValidateExternalleafRefObservation, error)

func (*NopValidator) ValidateLocalleafRef added in v0.4.15

func (*NopValidator) ValidateParentDependency added in v0.4.15

func (e *NopValidator) ValidateParentDependency(ctx context.Context, mg resource.Managed, cfg []byte) (ValidationParentDependencyObservation, error)

type Reconciler

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

A Reconciler reconciles managed resources by creating and managing the lifecycle of an external resource, i.e. a resource in an external network device through an API. Each controller must watch the managed resource kind for which it is responsible.

func NewReconciler

func NewReconciler(m manager.Manager, of resource.ManagedKind, o ...ReconcilerOption) *Reconciler

NewReconciler returns a Reconciler that reconciles managed resources of the supplied ManagedKind with resources in an external network device. It panics if asked to reconcile a managed resource kind that is not registered with the supplied manager's runtime.Scheme. The returned Reconciler 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 (*Reconciler) Reconcile

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

Reconcile a managed resource with an external resource.

type ReconcilerOption

type ReconcilerOption func(*Reconciler)

A ReconcilerOption configures a Reconciler.

func WithExternalConnecter

func WithExternalConnecter(c ExternalConnecter) ReconcilerOption

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

func WithExternalValidator

func WithExternalValidator(v Validator) ReconcilerOption

func WithFinalizer

func WithFinalizer(f resource.Finalizer) ReconcilerOption

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

func WithInitializers

func WithInitializers(i ...Initializer) ReconcilerOption

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

func WithLogger

func WithLogger(l logging.Logger) ReconcilerOption

WithLogger specifies how the Reconciler should log messages.

func WithPollInterval

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 an existing external resource needs to be synced to its ndd Managed resource.

func WithRecorder

func WithRecorder(er event.Recorder) ReconcilerOption

WithRecorder specifies how the Reconciler should record events.

func WithReferenceResolver

func WithReferenceResolver(rr ReferenceResolver) ReconcilerOption

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

func WithTimeout

func WithTimeout(duration time.Duration) ReconcilerOption

WithTimeout specifies the timeout duration cumulatively for all the calls happen in the reconciliation function. In case the deadline exceeds, reconciler will still have some time to make the necessary calls to report the error such as status update.

type ReferenceResolver

type ReferenceResolver interface {
	// ResolveReferences resolves all fields in the supplied managed resource
	// that are references to other managed resources by updating corresponding
	// fields, for example setting spec.network to the Network resource
	// specified by spec.networkRef.name.
	ResolveReferences(ctx context.Context, mg resource.Managed) error
}

A ReferenceResolver resolves references to other managed resources.

type ReferenceResolverFn

type ReferenceResolverFn func(context.Context, resource.Managed) error

A ReferenceResolverFn is a function that satisfies the ReferenceResolver interface.

func (ReferenceResolverFn) ResolveReferences

func (m ReferenceResolverFn) ResolveReferences(ctx context.Context, mg resource.Managed) error

ResolveReferences calls ReferenceResolverFn function

type ValidateExternalleafRefObservation added in v0.4.15

type ValidateExternalleafRefObservation struct {
	Success bool

	Details string
}

type ValidateLocalleafRefObservation added in v0.4.15

type ValidateLocalleafRefObservation struct {
	Success bool

	Details string
}

type ValidationParentDependencyObservation added in v0.4.15

type ValidationParentDependencyObservation struct {
	Success bool

	Details string
}

type Validator added in v0.4.15

type Validator interface {
	ValidateLocalleafRef(ctx context.Context, mg resource.Managed) (ValidateLocalleafRefObservation, error)

	ValidateExternalleafRef(ctx context.Context, mg resource.Managed, cfg []byte) (ValidateExternalleafRefObservation, error)

	ValidateParentDependency(ctx context.Context, mg resource.Managed, cfg []byte) (ValidationParentDependencyObservation, error)
}

type ValidatorFn added in v0.4.15

type ValidatorFn struct {
	ValidateLocalleafRefFn     func(ctx context.Context, mg resource.Managed) (ValidateLocalleafRefObservation, error)
	ValidateExternalleafRefFn  func(ctx context.Context, mg resource.Managed, cfg []byte) (ValidateExternalleafRefObservation, error)
	ValidateParentDependencyFn func(ctx context.Context, mg resource.Managed, cfg []byte) (ValidationParentDependencyObservation, error)
}

func (ValidatorFn) ValidateExternalleafRef added in v0.4.15

func (e ValidatorFn) ValidateExternalleafRef(ctx context.Context, mg resource.Managed, cfg []byte) (ValidateExternalleafRefObservation, error)

func (ValidatorFn) ValidateLocalleafRef added in v0.4.15

func (ValidatorFn) ValidateParentDependency added in v0.4.15

func (e ValidatorFn) ValidateParentDependency(ctx context.Context, mg resource.Managed, cfg []byte) (ValidationParentDependencyObservation, error)

Jump to

Keyboard shortcuts

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