directbase

package
v1.125.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: Apache-2.0 Imports: 37 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

func FindStatusCondition added in v1.123.0

func FindStatusCondition(conditions []v1alpha1.Condition, conditionType string) *v1alpha1.Condition

FindStatusCondition finds the conditionType in conditions.

func SetStatusCondition added in v1.123.0

func SetStatusCondition(conditions *[]v1alpha1.Condition, newCondition v1alpha1.Condition)

SetStatusCondition sets the corresponding condition in conditions to newCondition. conditions must be non-nil.

  1. if the condition of the specified type already exists (all fields of the existing condition are updated to newCondition, LastTransitionTime is set to now if the new status differs from the old status)
  2. if a condition of the specified type does not exist (LastTransitionTime is set to now() if unset, and newCondition is appended)

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(client client.Client, object *unstructured.Unstructured) *CreateOperation

func (*CreateOperation) GetUnstructured added in v1.122.0

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

GetUnstructured returns the object being reconciled, in unstructured format.

func (*CreateOperation) RequestRequeue added in v1.123.0

func (o *CreateOperation) RequestRequeue()

RequestRequeue requests a requeue of the operation, by returning Requeue = true from the reconcile loop.

func (*CreateOperation) UpdateStatus added in v1.123.0

func (o *CreateOperation) UpdateStatus(ctx context.Context, typedStatus any, readyCondition *v1alpha1.Condition) error

UpdateStatus writes the status and ready condition to the object's status subresource. We split out the readyCondition so that we will not write it from the reconcile loop if we wrote it here.

type DeleteOperation added in v1.122.0

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

func NewDeleteOperation added in v1.122.0

func NewDeleteOperation(client client.Client, 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 Operation added in v1.123.0

type Operation interface {
	// Writes the status and ready condition to the object's status subresource.
	// We split out the readyCondition so that we will not write it from the reconcile loop if we wrote it here.
	UpdateStatus(ctx context.Context, typedStatus any, readyCondition *v1alpha1.Condition) error

	// RequestRequeue requests a requeue of the operation, by returning Requeue = true from the reconcile loop.
	RequestRequeue()
}

Operation defines some functionality supported by all operation types.

type UpdateOperation added in v1.122.0

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

func NewUpdateOperation added in v1.122.0

func NewUpdateOperation(lifecycleHandler lifecyclehandler.LifecycleHandler, client client.Client, object *unstructured.Unstructured) *UpdateOperation

func (*UpdateOperation) GetUnstructured added in v1.122.0

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

GetUnstructured returns the object being reconciled, in unstructured format.

func (*UpdateOperation) RecordUpdatingEvent added in v1.125.0

func (o *UpdateOperation) RecordUpdatingEvent()

func (*UpdateOperation) RequestRequeue added in v1.123.0

func (o *UpdateOperation) RequestRequeue()

RequestRequeue requests a requeue of the operation, by returning Requeue = true from the reconcile loop.

func (*UpdateOperation) UpdateStatus added in v1.123.0

func (o *UpdateOperation) UpdateStatus(ctx context.Context, typedStatus any, readyCondition *v1alpha1.Condition) error

UpdateStatus writes the status and ready condition to the object's status subresource. We split out the readyCondition so that we will not write it from the reconcile loop if we wrote it here.

Jump to

Keyboard shortcuts

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