integrations

package
v0.0.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

type Provider interface {
	Reconcile(context.Context) (*ctrl.Result, error)
	Terminate(context.Context) (*ctrl.Result, error)
}

type ProviderConfig

type ProviderConfig struct {
	Workspace  *sequencer.Workspace
	Controller ProviderController
}

type ProviderController

type ProviderController interface {

	// Guard should be used whenever a condition needs to mutate an external resource (cloud features likes DNS, Tunneling, etc.)
	// Using a Guard makes has 2 purposes, locking a condition to avoid creating duplicate of resources, and a safety trigger by
	// making sure the underlying resource is not outdated.
	//
	// Reconciliation in a distributed system is always a little tricky as it uses eventual consistency. This means that
	// the resource the reconciler is operating on could be outdated. When that happens, the operator only knows about it when
	// it tries to mutate the object, in our case, the status subresource. By locking the specific condition, the operator will
	// know if the resource has a conflict before starting. This helps avoiding conflict errors when trying to update the status
	// with information about newly created cloud resources.
	//
	// Eventually, this Guard might not be as needed when the operator uses patches instead of update for these kind of critical
	// updates to the Status subresource.
	Guard(ctx context.Context, reason string, task Task) error

	// UpdateCondition is a helper function to only update the status of the condition attached to this controller. This is
	// useful when a condition needs to change but nothing else about the status has changed.
	UpdateCondition(ctx context.Context, status conditions.ConditionStatus, reason string) error

	// Update the status of the attached workspace. An integration might need to update one of the status field.
	Update(context.Context, workspaces.Status) error

	Create(context.Context, client.Object, ...client.CreateOption) error
	Delete(context.Context, client.Object, ...client.DeleteOption) error

	SetFinalizer(ctx context.Context, finalizer string) error
	RemoveFinalizer(ctx context.Context, finalizer string) error

	// Retrieve the associated workspace for this instance
	Workspace() *sequencer.Workspace

	// Return the condition that is currently being processed by this controller
	// The condition object can change, but the Type of the condition should always be the same
	// throughout the controller's lifetime.
	Condition() conditions.Condition

	// Namespace of the Workspace. This is the same as calling Workspace().namespace
	Namespace() string

	// Proxy method to the underlying reconciler's eventRecorder. The object is always set
	// to the attached Workspace.
	Event(eventtype string, reason string, message string)
	Eventf(eventtype string, reason string, messageFmt string, args ...interface{})

	// Allows the integration to read any K8s objects it needs to operate.
	client.Reader
}

ProviderController is the interface that will be passed to a 3rd party provider to interact with the reconciler loop and all the operator's resource. The goal of this controller is to provide an abstraction to allow 3rd party integrations to safely make changes to any of the records. The idea is not to be restrictive about what an intergration can do but rather allow those to not have to think about all the gotchas of using a reconciler loop.

func NewController

func NewController(workspace *sequencer.Workspace, condition conditions.Condition, reconciler Reconciler) ProviderController

type Task

type Task func() (status conditions.ConditionStatus, reason string, err error)

Jump to

Keyboard shortcuts

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