v1

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2022 License: MIT Imports: 16 Imported by: 2

Documentation

Overview

Package v1 contains helpers to build an operator component of a controller reconciler. It provides patterns and tools to structure the operator implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompositeOperator

type CompositeOperator struct {
	Operands []operand.Operand
	DAG      *dag.OperandDAG
	// contains filtered or unexported fields
}

CompositeOperator contains all the operands and the relationship between them. It implements the Operator interface.

func NewCompositeOperator

func NewCompositeOperator(opts ...CompositeOperatorOption) (*CompositeOperator, error)

NewCompositeOperator creates a composite operator with a list of operands. It evaluates the operands for valid, creating a relationship model between the model and returns a CompositeOperator. The relationship model between the operands is made using a directed acyclic graph(DAG). If the relationships do not form a proper DAG, an error is returned.

func (*CompositeOperator) Cleanup

func (co *CompositeOperator) Cleanup(ctx context.Context, obj client.Object) (result ctrl.Result, rerr error)

Cleanup implements the Operator interface.

func (*CompositeOperator) Ensure

func (co *CompositeOperator) Ensure(ctx context.Context, obj client.Object, ownerRef metav1.OwnerReference) (ctrl.Result, error)

Ensure implements the Operator interface. It runs all the operands, in the order of their dependencies, to ensure all the operations the individual operands perform.

func (*CompositeOperator) IsSuspended

func (co *CompositeOperator) IsSuspended(ctx context.Context, obj client.Object) bool

IsSuspend implements the Operator interface. It checks if the operator can run or if it's suspended and shouldn't run.

func (*CompositeOperator) Order

Order returns the order at which the operands depends on each other. This can be used for creation and deletion of all the resource, if used in reverse order.

type CompositeOperatorOption

type CompositeOperatorOption func(*CompositeOperator)

CompositeOperatorOption is used to configure CompositeOperator.

func WithEventRecorder

func WithEventRecorder(recorder record.EventRecorder) CompositeOperatorOption

WithEventRecorder sets the EventRecorder of a CompositeOperator.

func WithExecutionStrategy

func WithExecutionStrategy(strategy executor.ExecutionStrategy) CompositeOperatorOption

WithExecutionStrategy sets the execution strategy of a CompositeOperator.

func WithInstrumentation

WithInstrumentation configures the instrumentation of the CompositeOperator.

func WithOperands

func WithOperands(operands ...operand.Operand) CompositeOperatorOption

WithOperands sets the set of operands in a CompositeOperator.

func WithRetryPeriod

func WithRetryPeriod(duration time.Duration) CompositeOperatorOption

WithRetryPeriod sets the wait period of the operator before performing a retry in the event of a failure.

func WithSuspensionCheck

func WithSuspensionCheck(f func(context.Context, client.Object) bool) CompositeOperatorOption

SetIsSuspended can be used to set the operator suspension check.

type Operator

type Operator interface {
	// IsSuspended tells if an operator is suspended and should not run any
	// operation.
	IsSuspended(context.Context, client.Object) bool

	// Ensure runs all the operands' Ensure method in order defined by their
	// dependencies.
	Ensure(context.Context, client.Object, metav1.OwnerReference) (result ctrl.Result, err error)

	// Cleanup runs all the operands' Delete method in reverse order defined by
	// their dependencies.
	Cleanup(context.Context, client.Object) (result ctrl.Result, err error)
}

Operator is the operator interface that can be implemented by an operator to be used in a controller control loop.

Directories

Path Synopsis
Package dag helps create a directed asyclic graph(DAG) of the operands in an operator based on the relationship between the operands.
Package dag helps create a directed asyclic graph(DAG) of the operands in an operator based on the relationship between the operands.
Package executor contains types and functions to help with the execution of the operands.
Package executor contains types and functions to help with the execution of the operands.
Package operand defines an operand interface.
Package operand defines an operand interface.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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