kubebuilderx

package
v0.9.3-beta.13 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Package kubebuilderx is a new framework builds upon the original DAG framework, which abstracts the reconciliation process into two stages. The first stage is the pure computation phase, where the goal is to generate an execution plan. The second stage is the plan execution phase, responsible for applying the changes computed in the first stage to the K8s API server. The design choice of making the first stage purely computational serves two purposes. Firstly, it allows leveraging the experience and patterns from functional programming to make the code more robust. Secondly, it enables breaking down complex business logic into smaller units, facilitating testing. The new framework retains this concept while attempting to address the following issues of the original approach: 1. The low-level exposure of the DAG data structure, which should be abstracted away. 2. The execution of business logic code being deferred, making step-by-step tracing and debugging challenging. Additionally, the new framework further abstracts the concept of object snapshots into an ObjectTree, making it easier to apply the experience of editing a group of related objects using kubectl.

KubeBuilderX is in its very early stage.

Index

Constants

This section is empty.

Variables

View Source
var Commit = Result{Next: cmmt}
View Source
var ConditionSatisfied = &CheckResult{Satisfied: true}
View Source
var ConditionUnsatisfied = &CheckResult{}
View Source
var Continue = Result{Next: cntn}
View Source
var ErrDeepCopyFailed = errors.New("DeepCopyFailed")

Functions

func NewPlanBuilder

func NewPlanBuilder(ctx context.Context, cli client.Client, currentTree, desiredTree *ObjectTree, recorder record.EventRecorder, logger logr.Logger) graph.PlanBuilder

NewPlanBuilder returns a PlanBuilder

Types

type CheckResult

type CheckResult struct {
	Satisfied bool
	Err       error
}

func CheckResultWithError

func CheckResultWithError(err error) *CheckResult

type Controller

type Controller interface {
	Prepare(TreeLoader) Controller
	Do(...Reconciler) Controller
	Commit() (ctrl.Result, error)
}

func NewController

func NewController(ctx context.Context, cli client.Client, req ctrl.Request, recorder record.EventRecorder, logger logr.Logger) Controller

type ObjectTree

type ObjectTree struct {
	// TODO(free6om): should find a better place to hold these two params?
	record.EventRecorder
	logr.Logger
	// contains filtered or unexported fields
}

func NewObjectTree

func NewObjectTree() *ObjectTree

func ReadObjectTree

func ReadObjectTree[T client.Object](ctx context.Context, reader client.Reader, req ctrl.Request, ml client.MatchingLabels, kinds ...client.ObjectList) (*ObjectTree, error)

ReadObjectTree reads all objects owned by the root object which is type of 'T' with key in 'req'.

func (*ObjectTree) Add

func (t *ObjectTree) Add(objects ...client.Object) error

func (*ObjectTree) DeepCopy

func (t *ObjectTree) DeepCopy() (*ObjectTree, error)

func (*ObjectTree) Delete

func (t *ObjectTree) Delete(objects ...client.Object) error

func (*ObjectTree) DeleteRoot

func (t *ObjectTree) DeleteRoot()

func (*ObjectTree) DeleteSecondaryObjects

func (t *ObjectTree) DeleteSecondaryObjects()

func (*ObjectTree) Get

func (t *ObjectTree) Get(object client.Object) (client.Object, error)

func (*ObjectTree) GetFinalizer

func (t *ObjectTree) GetFinalizer() string

func (*ObjectTree) GetRoot

func (t *ObjectTree) GetRoot() client.Object

func (*ObjectTree) GetSecondaryObjects

func (t *ObjectTree) GetSecondaryObjects() model.ObjectSnapshot

func (*ObjectTree) List

func (t *ObjectTree) List(obj client.Object) []client.Object

func (*ObjectTree) SetFinalizer

func (t *ObjectTree) SetFinalizer(finalizer string)

func (*ObjectTree) SetRoot

func (t *ObjectTree) SetRoot(root client.Object)

func (*ObjectTree) Update

func (t *ObjectTree) Update(objects ...client.Object) error

type Plan

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

func (*Plan) Execute

func (p *Plan) Execute() error

type PlanBuilder

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

func (*PlanBuilder) AddParallelTransformer

func (b *PlanBuilder) AddParallelTransformer(_ ...graph.Transformer) graph.PlanBuilder

func (*PlanBuilder) AddTransformer

func (b *PlanBuilder) AddTransformer(_ ...graph.Transformer) graph.PlanBuilder

func (*PlanBuilder) Build

func (b *PlanBuilder) Build() (graph.Plan, error)

func (*PlanBuilder) Init

func (b *PlanBuilder) Init() error

type Reconciler

type Reconciler interface {
	PreCondition(*ObjectTree) *CheckResult
	Reconcile(tree *ObjectTree) (Result, error)
}

type Result added in v0.9.1

type Result struct {
	Next       controlMethod
	RetryAfter time.Duration
}

func RetryAfter added in v0.9.1

func RetryAfter(after time.Duration) Result

type TreeLoader

type TreeLoader interface {
	Load(context.Context, client.Reader, ctrl.Request, record.EventRecorder, logr.Logger) (*ObjectTree, error)
}

Jump to

Keyboard shortcuts

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