Documentation ¶
Index ¶
- func ControllerName(kind string) string
- func FindExternalResourceNameDelta(oldSlice, newSlice []string) []string
- type ConnectionDetails
- type ExternalClient
- type ExternalClientFns
- func (e ExternalClientFns) Create(ctx context.Context, mg resource.Managed) (ExternalCreation, error)
- func (e ExternalClientFns) Delete(ctx context.Context, mg resource.Managed) error
- func (e ExternalClientFns) GetConfig(ctx context.Context) ([]byte, error)
- func (e ExternalClientFns) GetResourceName(ctx context.Context, path []*gnmi.Path) (string, error)
- func (e ExternalClientFns) GetTarget() []string
- func (e ExternalClientFns) Observe(ctx context.Context, mg resource.Managed) (ExternalObservation, error)
- func (e ExternalClientFns) Update(ctx context.Context, mg resource.Managed) (ExternalUpdate, error)
- type ExternalConnecter
- type ExternalConnectorFn
- type ExternalCreation
- type ExternalObservation
- type ExternalUpdate
- type FinalizerOperation
- type NopClient
- func (c *NopClient) Create(ctx context.Context, mg resource.Managed) (ExternalCreation, error)
- func (c *NopClient) Delete(ctx context.Context, mg resource.Managed) error
- func (c *NopClient) GetConfig(ctx context.Context) ([]byte, error)
- func (c *NopClient) GetResourceName(ctx context.Context, path []*gnmi.Path) (string, error)
- func (c *NopClient) GetTarget() []string
- func (c *NopClient) Observe(ctx context.Context, mg resource.Managed) (ExternalObservation, error)
- func (c *NopClient) Update(ctx context.Context, mg resource.Managed, obs ExternalObservation) (ExternalUpdate, error)
- type NopConnecter
- type NopValidator
- func (e *NopValidator) ValidateExternalleafRef(ctx context.Context, mg resource.Managed, cfg []byte) (ValidateExternalleafRefObservation, error)
- func (e *NopValidator) ValidateLocalleafRef(ctx context.Context, mg resource.Managed) (ValidateLocalleafRefObservation, error)
- func (e *NopValidator) ValidateParentDependency(ctx context.Context, mg resource.Managed, cfg []byte) (ValidateParentDependencyObservation, error)
- func (e *NopValidator) ValidateResourceIndexes(ctx context.Context, mg resource.Managed) (ValidateResourceIndexesObservation, error)
- type Reconciler
- type ReconcilerOption
- func WithExternalConnecter(c ExternalConnecter) ReconcilerOption
- func WithFinalizer(f resource.Finalizer) ReconcilerOption
- func WithLogger(l logging.Logger) ReconcilerOption
- func WithParser(l logging.Logger) ReconcilerOption
- func WithPollInterval(after time.Duration) ReconcilerOption
- func WithRecorder(er event.Recorder) ReconcilerOption
- func WithTimeout(duration time.Duration) ReconcilerOption
- func WithValidator(v Validator) ReconcilerOption
- type ValidateExternalleafRefObservation
- type ValidateLocalleafRefObservation
- type ValidateParentDependencyObservation
- type ValidateResourceIndexesObservation
- type Validator
- type ValidatorFn
- func (e ValidatorFn) ValidateExternalleafRef(ctx context.Context, mg resource.Managed, cfg []byte) (ValidateExternalleafRefObservation, error)
- func (e ValidatorFn) ValidateLocalleafRef(ctx context.Context, mg resource.Managed) (ValidateLocalleafRefObservation, error)
- func (e ValidatorFn) ValidateParentDependency(ctx context.Context, mg resource.Managed, cfg []byte) (ValidateParentDependencyObservation, error)
- func (e ValidatorFn) ValidateResourceIndexes(ctx context.Context, mg resource.Managed) (ValidateResourceIndexesObservation, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ControllerName ¶ added in v0.3.65
ControllerName returns the recommended name for controllers that use this package to reconcile a particular kind of managed resource.
func FindExternalResourceNameDelta ¶ added in v0.4.86
Types ¶
type ConnectionDetails ¶
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, obs ExternalObservation) (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) // GetResourceName returns the resource that matches the path GetResourceName(ctx context.Context, path []*gnmi.Path) (string, 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) GetResourceNameFn func(ctx context.Context, path []*gnmi.Path) (string, error) }
ExternalClientFns are a series of functions that satisfy the ExternalClient interface.
func (ExternalClientFns) Create ¶
func (e ExternalClientFns) Create(ctx context.Context, mg resource.Managed) (ExternalCreation, error)
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) GetResourceName ¶ added in v0.4.20
GetResourceName returns the resource matching the path
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 ¶
func (e ExternalClientFns) Observe(ctx context.Context, mg resource.Managed) (ExternalObservation, error)
Observe the external resource the supplied Managed resource represents, if any.
func (ExternalClientFns) Update ¶
func (e ExternalClientFns) Update(ctx context.Context, mg resource.Managed) (ExternalUpdate, error)
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 ¶
An ExternalConnectorFn is a function that satisfies the ExternalConnecter interface.
func (ExternalConnectorFn) Connect ¶
func (ec ExternalConnectorFn) Connect(ctx context.Context, mg resource.Managed) (ExternalClient, error)
Connect to the provider specified by the supplied managed resource and produce an ExternalClient.
type ExternalCreation ¶
type ExternalCreation struct { }
type ExternalObservation ¶
type ExternalObservation struct { // indicated if the cache is ready or not, during cache startup this can occur // when the cache is still initializing Ready bool // ResourceExists must be true if a corresponding external resource exists // for the managed resource. This is checked using the resourceKey in the // device driver ResourceExists bool // ResourceHasData can be true when a managed resource is created, but the // device had already data in that resource. The data needs to get aligned // with the intended resource data ResourceHasData bool // ResourceUpToDate should be true if the corresponding external resource // appears to be up-to-date ResourceUpToDate bool ResourceDeletes []*gnmi.Path ResourceUpdates []*gnmi.Update }
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 FinalizerOperation ¶ added in v0.4.102
type FinalizerOperation string
A OperationType represents an operatio on a JSON resource
const ( // add FinalizerOperationAdd FinalizerOperation = "Add" // remove FinalizerOperationRemove FinalizerOperation = "Remove" )
Condition Kinds.
type NopClient ¶
type NopClient struct{}
A NopClient does nothing.
func (*NopClient) GetConfig ¶ added in v0.4.15
GetConfig returns the full configuration of the network node
func (*NopClient) GetResourceName ¶ added in v0.4.20
GetResourceName returns the resource matching the path
func (*NopClient) Observe ¶
Observe does nothing. It returns an empty ExternalObservation and no error.
func (*NopClient) Update ¶
func (c *NopClient) Update(ctx context.Context, mg resource.Managed, obs ExternalObservation) (ExternalUpdate, error)
Update does nothing. It returns an empty ExternalUpdate and no error.
type NopConnecter ¶
type NopConnecter struct{}
A NopConnecter does nothing.
func (*NopConnecter) Connect ¶
func (c *NopConnecter) Connect(_ context.Context, _ resource.Managed) (ExternalClient, error)
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 (e *NopValidator) ValidateLocalleafRef(ctx context.Context, mg resource.Managed) (ValidateLocalleafRefObservation, error)
func (*NopValidator) ValidateParentDependency ¶ added in v0.4.15
func (e *NopValidator) ValidateParentDependency(ctx context.Context, mg resource.Managed, cfg []byte) (ValidateParentDependencyObservation, error)
func (*NopValidator) ValidateResourceIndexes ¶ added in v0.4.89
func (e *NopValidator) ValidateResourceIndexes(ctx context.Context, mg resource.Managed) (ValidateResourceIndexesObservation, 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) HandleExternalResourceFinalizer ¶ added in v0.4.102
func (r *Reconciler) HandleExternalResourceFinalizer(ctx context.Context, operation FinalizerOperation, externalResourceName string, managed resource.Managed) error
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 WithFinalizer ¶
func WithFinalizer(f resource.Finalizer) ReconcilerOption
WithFinalizer specifies how the Reconciler should add and remove finalizers to and from the managed resource.
func WithLogger ¶
func WithLogger(l logging.Logger) ReconcilerOption
WithLogger specifies how the Reconciler should log messages.
func WithParser ¶ added in v0.4.82
func WithParser(l logging.Logger) ReconcilerOption
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 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.
func WithValidator ¶ added in v0.4.15
func WithValidator(v Validator) ReconcilerOption
type ValidateExternalleafRefObservation ¶ added in v0.4.15
type ValidateExternalleafRefObservation struct { Success bool ResolvedLeafRefs []*parser.ResolvedLeafRefGnmi }
type ValidateLocalleafRefObservation ¶ added in v0.4.15
type ValidateLocalleafRefObservation struct { Success bool ResolvedLeafRefs []*parser.ResolvedLeafRefGnmi }
type ValidateParentDependencyObservation ¶ added in v0.4.89
type ValidateParentDependencyObservation struct { Success bool ResolvedLeafRefs []*parser.ResolvedLeafRefGnmi }
type ValidateResourceIndexesObservation ¶ added in v0.4.89
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) (ValidateParentDependencyObservation, error) ValidateResourceIndexes(ctx context.Context, mg resource.Managed) (ValidateResourceIndexesObservation, 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) (ValidateParentDependencyObservation, error) ValidateResourceIndexesFn func(ctx context.Context, mg resource.Managed) (ValidateResourceIndexesObservation, 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 (e ValidatorFn) ValidateLocalleafRef(ctx context.Context, mg resource.Managed) (ValidateLocalleafRefObservation, error)
func (ValidatorFn) ValidateParentDependency ¶ added in v0.4.15
func (e ValidatorFn) ValidateParentDependency(ctx context.Context, mg resource.Managed, cfg []byte) (ValidateParentDependencyObservation, error)
func (ValidatorFn) ValidateResourceIndexes ¶ added in v0.4.89
func (e ValidatorFn) ValidateResourceIndexes(ctx context.Context, mg resource.Managed) (ValidateResourceIndexesObservation, error)