directbase

package
v1.118.1 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(mgr manager.Manager, gvk schema.GroupVersionKind, model Model, opts Deps) error

Add creates a new controller for reconciling objects of the specified GVK, delegating actual resource reconciliation to the provided Model.

Types

type Adapter

type Adapter interface {
	// Delete removes the GCP object.
	// This can be called without calling Find.
	// It returns (true, nil) if the object was deleted,
	// and (false, nil) if the object was not found but should be presumed deleted.
	// In an error, the state is not fully determined - a delete might be in progress.
	Delete(ctx context.Context) (deleted bool, err error)

	// Find must be called as the first operation (unless we are deleting).
	// It returns whether the corresponding GCP object was found.
	Find(ctx context.Context) (found bool, err error)

	// Create creates a new GCP object.
	// This should only be called when Find has previously returned false.
	// The implementation should write the updated status into `u`.
	Create(ctx context.Context, u *unstructured.Unstructured) error

	// Update updates an existing GCP object.
	// This should only be called when Find has previously returned true.
	// The implementation should write the updated status into `u`.
	Update(ctx context.Context, u *unstructured.Unstructured) error

	// Export fetches the cloud provider's representation of the object
	// as an unstructured.Unstructured.
	// Assumes Find has previously returned true.
	Export(ctx context.Context) (*unstructured.Unstructured, error)
}

Adapter performs a single reconciliation on a single object. It is built using AdapterForObject.

type Deps added in v1.117.0

type Deps struct {
	JitterGenerator jitter.Generator
}

type DirectReconciler

type DirectReconciler struct {
	lifecyclehandler.LifecycleHandler
	client.Client
	metrics.ReconcilerMetrics
	// contains filtered or unexported fields
}

DirectReconciler is a reconciler for reconciling resources that support the Model/Adapter pattern. It is currently an adaptation of the existing terraform based-reconciler, and thus uses things like k8s.Resource. TODO: Move away from k8s.Resource to unstructured.Unstructured.

func NewReconciler

func NewReconciler(mgr manager.Manager, immediateReconcileRequests chan event.GenericEvent, resourceWatcherRoutines *semaphore.Weighted,
	gvk schema.GroupVersionKind, model Model, jg jitter.Generator) (*DirectReconciler, error)

NewReconciler returns a new reconcile.Reconciler.

func (*DirectReconciler) Reconcile

func (r *DirectReconciler) Reconcile(ctx context.Context, request reconcile.Request) (result reconcile.Result, err error)

Reconcile checks k8s for the current state of the resource.

type Model

type Model interface {
	// AdapterForObject builds an operation object for reconciling the object u.
	// If there are references, AdapterForObject should dereference them before returning (using reader)
	AdapterForObject(ctx context.Context, reader client.Reader, u *unstructured.Unstructured) (Adapter, error)
}

Model is the entry-point for our per-object reconcilers

Jump to

Keyboard shortcuts

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