Documentation ¶
Index ¶
- func ControllerName(kind string) string
- type ConnectionDetails
- type ExternalClient
- type ExternalClientFns
- func (e ExternalClientFns) Close()
- func (e ExternalClientFns) Create(ctx context.Context, tr tresource.Transaction, gvkList []string) error
- func (e ExternalClientFns) Delete(ctx context.Context, tr tresource.Transaction, gvkList []string) error
- func (e ExternalClientFns) Observe(ctx context.Context, tr tresource.Transaction) (ExternalObservation, error)
- type ExternalConnecter
- type ExternalConnectorFn
- type ExternalObservation
- type Handler
- type HandlerFn
- type NopClient
- func (c *NopClient) Close()
- func (c *NopClient) Create(ctx context.Context, tr tresource.Transaction, gvkList []string) error
- func (c *NopClient) Delete(ctx context.Context, tr tresource.Transaction, gvkList []string) error
- func (c *NopClient) Observe(ctx context.Context, tr tresource.Transaction) (ExternalObservation, error)
- type NopConnecter
- type NopHandler
- type Reconciler
- type ReconcilerOption
- func WithExternalConnecter(c ExternalConnecter) ReconcilerOption
- func WithFinalizer(f tresource.Finalizer) ReconcilerOption
- func WithHandler(h Handler) ReconcilerOption
- func WithLogger(l logging.Logger) ReconcilerOption
- func WithPollInterval(after time.Duration) ReconcilerOption
- func WithRecorder(er event.Recorder) ReconcilerOption
- func WithTimeout(duration time.Duration) ReconcilerOption
Constants ¶
This section is empty.
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 managed resource.
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 transaction in the cache Observe(ctx context.Context, tr tresource.Transaction) (ExternalObservation, error) // Create a transaction in the cache Create(ctx context.Context, tr tresource.Transaction, gvkList []string) error // Delete a transaction in the cache Delete(ctx context.Context, tr tresource.Transaction, gvkList []string) error // Close Close() }
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, tr tresource.Transaction) (ExternalObservation, error) CreateFn func(ctx context.Context, tr tresource.Transaction, gvkList []string) error DeleteFn func(ctx context.Context, tr tresource.Transaction, gvkList []string) error CloseFn func() }
ExternalClientFns are a series of functions that satisfy the ExternalClient interface.
func (ExternalClientFns) Close ¶
func (e ExternalClientFns) Close()
GetResourceName returns the resource matching the path
func (ExternalClientFns) Create ¶
func (e ExternalClientFns) Create(ctx context.Context, tr tresource.Transaction, gvkList []string) error
Create an external resource per the specifications of the supplied Managed resource.
func (ExternalClientFns) Delete ¶
func (e ExternalClientFns) Delete(ctx context.Context, tr tresource.Transaction, gvkList []string) error
Delete the external resource upon deletion of its associated Managed resource.
func (ExternalClientFns) Observe ¶
func (e ExternalClientFns) Observe(ctx context.Context, tr tresource.Transaction) (ExternalObservation, error)
Observe the external resource the supplied Managed resource represents, if any.
type ExternalConnecter ¶
type ExternalConnecter interface { // Connect to the provider specified by the supplied managed resource and // produce an ExternalClient. Connect(ctx context.Context, tr tresource.Transaction, deviceName string) (ExternalClient, error) }
An ExternalConnecter produces a new ExternalClient given the supplied Managed resource.
type ExternalConnectorFn ¶
type ExternalConnectorFn func(ctx context.Context, tr tresource.Transaction, deviceName string) (ExternalClient, error)
An ExternalConnectorFn is a function that satisfies the ExternalConnecter interface.
func (ExternalConnectorFn) Connect ¶
func (ec ExternalConnectorFn) Connect(ctx context.Context, tr tresource.Transaction, deviceName string) (ExternalClient, error)
Connect to the provider specified by the supplied managed resource and produce an ExternalClient.
type ExternalObservation ¶
type ExternalObservation struct { // indicated if the cache is exhausted or not, can reflect the status of the devic Exhausted bool // 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 transaction exists in the cache // but status is pending Exists bool // indicates if the transaction was successfully applied to the device or not // represents failed or success status of the transaction Success bool // inidcates the Pending bool // the gvk resources applied to the cache GvkResourceList []*systemv1alpha1.Gvk }
An ExternalObservation is the result of an observation of an external resource.
type HandlerFn ¶
type NopClient ¶
type NopClient struct{}
A NopClient does nothing.
func (*NopClient) Observe ¶
func (c *NopClient) Observe(ctx context.Context, tr tresource.Transaction) (ExternalObservation, error)
Observe does nothing. It returns an empty ExternalObservation and no error.
type NopConnecter ¶
type NopConnecter struct{}
A NopConnecter does nothing.
func (*NopConnecter) Connect ¶
func (c *NopConnecter) Connect(_ context.Context, _ tresource.Transaction, _ string) (ExternalClient, error)
Connect returns a NopClient. It never returns an error.
type NopHandler ¶
type NopHandler struct{}
func (*NopHandler) GetResources ¶
func (e *NopHandler) GetResources(ctx context.Context, tr tresource.Transaction) (map[string]map[string]map[string]interface{}, 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 tresource.TransactionKind, 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.
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 tresource.Finalizer) ReconcilerOption
WithFinalizer specifies how the Reconciler should add and remove finalizers to and from the managed resource.
func WithHandler ¶ added in v0.2.25
func WithHandler(h Handler) ReconcilerOption
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 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.