directbase

package
v1.122.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddController added in v1.119.0

func AddController(mgr manager.Manager, gvk schema.GroupVersionKind, model Model, deps Deps) error

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, op *DeleteOperation) (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, op *CreateOperation) 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, op *UpdateOperation) 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 CreateOperation added in v1.122.0

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

func NewCreateOperation added in v1.122.0

func NewCreateOperation(object *unstructured.Unstructured) *CreateOperation

func (*CreateOperation) GetUnstructured added in v1.122.0

func (o *CreateOperation) GetUnstructured() *unstructured.Unstructured

type DeleteOperation added in v1.122.0

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

func NewDeleteOperation added in v1.122.0

func NewDeleteOperation(object *unstructured.Unstructured) *DeleteOperation

func (*DeleteOperation) GetUnstructured added in v1.122.0

func (o *DeleteOperation) GetUnstructured() *unstructured.Unstructured

type Deps added in v1.117.0

type Deps struct {
	JitterGenerator    jitter.Generator
	ReconcilePredicate predicate.Predicate
}

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)

	// AdapterForURL builds an operation object for exporting the object u.
	AdapterForURL(ctx context.Context, url string) (Adapter, error)
}

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

type UpdateOperation added in v1.122.0

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

func NewUpdateOperation added in v1.122.0

func NewUpdateOperation(object *unstructured.Unstructured) *UpdateOperation

func (*UpdateOperation) GetUnstructured added in v1.122.0

func (o *UpdateOperation) GetUnstructured() *unstructured.Unstructured

Jump to

Keyboard shortcuts

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