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 ¶
- Variables
- func NewPlanBuilder(ctx context.Context, cli client.Client, currentTree, desiredTree *ObjectTree, ...) graph.PlanBuilder
- type CheckResult
- type Controller
- type ObjectTree
- func (t *ObjectTree) Add(objects ...client.Object) error
- func (t *ObjectTree) DeepCopy() (*ObjectTree, error)
- func (t *ObjectTree) Delete(objects ...client.Object) error
- func (t *ObjectTree) DeleteRoot()
- func (t *ObjectTree) DeleteSecondaryObjects()
- func (t *ObjectTree) Get(object client.Object) (client.Object, error)
- func (t *ObjectTree) GetFinalizer() string
- func (t *ObjectTree) GetRoot() client.Object
- func (t *ObjectTree) GetSecondaryObjects() model.ObjectSnapshot
- func (t *ObjectTree) List(obj client.Object) []client.Object
- func (t *ObjectTree) SetFinalizer(finalizer string)
- func (t *ObjectTree) SetRoot(root client.Object)
- func (t *ObjectTree) Update(objects ...client.Object) error
- type Plan
- type PlanBuilder
- type Reconciler
- type TreeLoader
Constants ¶
This section is empty.
Variables ¶
var ErrDeepCopyFailed = errors.New("DeepCopyFailed")
var ResultSatisfied = &CheckResult{Satisfied: true}
var ResultUnsatisfied = &CheckResult{}
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 ¶
func CheckResultWithError ¶
func CheckResultWithError(err error) *CheckResult
type Controller ¶
type Controller interface { Prepare(TreeLoader) Controller Do(...Reconciler) Controller Commit() error }
func NewController ¶
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) DeepCopy ¶
func (t *ObjectTree) DeepCopy() (*ObjectTree, error)
func (*ObjectTree) DeleteRoot ¶
func (t *ObjectTree) DeleteRoot()
func (*ObjectTree) DeleteSecondaryObjects ¶
func (t *ObjectTree) DeleteSecondaryObjects()
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) SetFinalizer ¶
func (t *ObjectTree) SetFinalizer(finalizer string)
func (*ObjectTree) SetRoot ¶
func (t *ObjectTree) SetRoot(root client.Object)
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) Init ¶
func (b *PlanBuilder) Init() error
type Reconciler ¶
type Reconciler interface { PreCondition(*ObjectTree) *CheckResult Reconcile(tree *ObjectTree) (*ObjectTree, error) }