directbase

package
v1.154.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: Apache-2.0 Imports: 44 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 AdapterForObjectOperation added in v1.145.0

type AdapterForObjectOperation struct {
	Reader client.Reader
	Object *unstructured.Unstructured
}

func (*AdapterForObjectOperation) GetUnstructured added in v1.145.0

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

func (*AdapterForObjectOperation) IsDeleting added in v1.145.0

func (o *AdapterForObjectOperation) IsDeleting() bool

type CreateOperation added in v1.122.0

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

func NewCreateOperation added in v1.122.0

func NewCreateOperation(lifecycleHandler lifecyclehandler.LifecycleHandler, client client.Client, object *unstructured.Unstructured) *CreateOperation

func (*CreateOperation) CompareLastModifiedCookie added in v1.145.0

func (o *CreateOperation) CompareLastModifiedCookie(desired, actual proto.Message) (bool, error)

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) RecordUpdatingEvent added in v1.130.1

func (o *CreateOperation) RecordUpdatingEvent()

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) SetLastModifiedCookie added in v1.145.0

func (o *CreateOperation) SetLastModifiedCookie(ctx context.Context, desired, actual proto.Message) error

func (*CreateOperation) SetSpecResourceID added in v1.141.0

func (o *CreateOperation) SetSpecResourceID(ctx context.Context, resourceID string) error

SetSpecResourceID sets the spec.resourceID field of the resource after creation. This was the previous behaviour for resources where the resource ID is server-generated. We now consider status.externalRef the canonical source of truth for resource identity, but we keep this function for backwards compatibility for server-generated-id resources that were previously managed by Terraform/DCL. More info in docs/ai/server-generated-id.md

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 {
	Defaulters      []k8s.Defaulter
	JitterGenerator jitter.Generator

	// There are Dependencies for Adapters in particular (not the reconcilers)
	IAMAdapterDeps *IAMAdapterDeps

	SkipNameValidation bool
}

Reconciler dependencies.

type DirectReconciler

type DirectReconciler struct {
	lifecyclehandler.LifecycleHandler
	client.Client
	metrics.ReconcilerMetrics

	SkipNameValidation bool
	// contains filtered or unexported fields
}

DirectReconciler is a reconciler for reconciling resources that support the Model/Adapter pattern.

func NewReconciler

func NewReconciler(mgr manager.Manager, immediateReconcileRequests chan event.GenericEvent, resourceWatcherRoutines *semaphore.Weighted,
	gvk schema.GroupVersionKind, model Model, deps Deps) (*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 IAMAdapterDeps added in v1.132.1

type IAMAdapterDeps struct {
	ControllerDeps *controller.Deps
	KubeClient     client.Client
}

TODO(kcc-team): we want to remove these in the future In a world where there are no TF or DCL based IAM resources, we don't need these dependencies and the "special" IAM model.

type IAMModel added in v1.132.1

type IAMModel interface {
	IAMAdapterForObject(ctx context.Context, reader client.Reader, u *unstructured.Unstructured, deps *IAMAdapterDeps) (Adapter, error)
}

IAMModel will instantiate the IAM controllers with dependecies to be able to interface with Terraform and DCL based IAM resources.

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, op *AdapterForObjectOperation) (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()

	// SetLastModifiedCookie sets the last-changed-cookie annotation on the object.
	SetLastModifiedCookie(ctx context.Context, desired, actual proto.Message) error

	// CompareLastModifiedCookie compares the last-changed-cookie annotation on the object with the hashes of the desired and actual state.
	CompareLastModifiedCookie(desired, actual proto.Message) (bool, error)
}

Operation defines some functionality supported by all operation types.

type SensitiveFieldModel added in v1.131.0

type SensitiveFieldModel 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, op *AdapterForObjectOperation) (Adapter, error)

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

	MapSecretToResources(ctx context.Context, reader client.Reader, secret corev1.Secret) ([]reconcile.Request, error)
}

SensitiveFieldModel is the entry-point for our per-object reconciler that handles CRD with sensitive fields.

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) CompareLastModifiedCookie added in v1.145.0

func (o *UpdateOperation) CompareLastModifiedCookie(desired, actual proto.Message) (bool, error)

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) SetLastModifiedCookie added in v1.145.0

func (o *UpdateOperation) SetLastModifiedCookie(ctx context.Context, desired, actual proto.Message) error

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