Categorygithub.com/risingwavelabs/ctrlkit
modulepackage
1.0.1
Repository: https://github.com/risingwavelabs/ctrlkit.git
Documentation: pkg.go.dev

# README

ctrlkit

Go Report Card GoDoc Build Status codecov License

ctrlkit is a library written in Go that expedites the development of Kubernetes controllers. It provides a set of interfaces and utilities that can be used to build controllers that are easy to test and maintain. The ctrlkit library is designed to be used in conjunction with the controller-runtime.

Use Cases

Contribution

Contributions are welcome! For more information, see CONTRIBUTING.

License

The project is licensed under the Apache 2.0 license. For more information, see LICENSE.

# Functions

ChainActionHooks creates a ChainedActionHooks with the given hooks.
Exit returns an empty result and an ErrExit.
ExitIf exits if the condition is true.
If returns the given action if predicate is true, or an Nop otherwise.
IfElse returns the action left if predicate is true, or the right otherwise.
IgnoreExit keeps the result but returns a nil when err == ErrExit.
Join organizes the actions in a split-join flow, which doesn't guarantee the execution order.
NeedsRequeue reports if the result and error indicates a requeue.
NewAction wraps the given description and function into an action.
NoRequeue returns an empty result and a nil.
OptimizeWorkflow optimizes the workflow by eliminating unnecessary layers: - Nop in Sequential or Join will be removed - Empty Join and Sequential will be omitted - Parallel in Sequential will be unwrapped - Sequential and Join with single child will be simplified by removing them - Sequential(Sequential) will be flattened - Join(Join) will be flattened - Parallel(Parallel) will be simplified with only one Parallel - Timeout(Timeout) will be simplified with the tighter timeout.
OrderedJoin organizes the actions in a split-join flow and guarantees the execution order.
Parallel wraps the action and runs it in parallel.
ParallelJoin organizes the actions in a split-join flow and executes them in parallel.
RequeueAfter returns a result with requeue after set to the given duration and a nil.
RequeueIfError returns an empty result with the err.
RequeueIfErrorAndWrap returns an empty result with a wrapped err.
RequeueImmediately returns a result with requeue set to true and a nil.
Retry wraps an action into a retryable action.
RetryInterval wraps an action into a retryable action.
Sequential organizes the actions into a sequential flow.
Shared wraps the action into a shared action.
Timeout wraps the reconcile action with a timeout.
ValidateOwnership validates the ownership by checking the owner references.

# Variables

Continue is an alias of NoRequeue.
ErrExit exits the workflow early.
Nop is a special action that does nothing.
SequentialJoin is an alias of JoinOrdered, because it runs the actions in both join and sequential style.

# Structs

ChainedActionHooks chains a sequence of hooks into one.

# Interfaces

ActionHook provides hooks for actions implementations in controller manager.

# Type aliases

Action is the basic unit to form a workflow.
ActionFunc is an alias for func(context.Context) (ctrl.Result, error).