Documentation ¶
Index ¶
- Variables
- func Debug(e *executor)
- type BaseReconcileContext
- func (rc *BaseReconcileContext) Apply(object client.Object) error
- func (rc *BaseReconcileContext) CSAApply(object client.Object, oldObject ...client.Object) error
- func (rc *BaseReconcileContext) Close() error
- func (rc *BaseReconcileContext) Context() context.Context
- func (rc *BaseReconcileContext) Get(object client.Object) error
- func (rc *BaseReconcileContext) List(list client.ObjectList, selector labels.Selector) error
- func (rc *BaseReconcileContext) Name() string
- func (rc *BaseReconcileContext) Namespace() string
- func (rc *BaseReconcileContext) Owner() client.FieldOwner
- func (rc *BaseReconcileContext) Patch(object client.Object, patch client.Patch, options ...client.PatchOption) error
- func (rc *BaseReconcileContext) Recorder() record.EventRecorder
- func (rc *BaseReconcileContext) Request() reconcile.Request
- type BindFunc
- func Abort(msg string) BindFunc
- func AbortWhen(cond bool, msg string) BindFunc
- func Block(binds ...BindFunc) BindFunc
- func Branch(cond bool, a, b BindFunc) BindFunc
- func CombineBinders(binders ...BindFunc) BindFunc
- func NewStepBinder(step Step) BindFunc
- func NewStepIfBinder(cond Condition, step Step) BindFunc
- func Retry(msg string) BindFunc
- func RetryAfter(d time.Duration, msg string) BindFunc
- func ScheduleAfter(d time.Duration) BindFunc
- func Wait(msg string) BindFunc
- func When(cond bool, a ...BindFunc) BindFunc
- type Condition
- type ConditionFunc
- type DefaultReconcileHelper
- func (rc *DefaultReconcileHelper) Client() client.Client
- func (rc *DefaultReconcileHelper) ClientSet() *kubernetes.Clientset
- func (rc *DefaultReconcileHelper) Debug() bool
- func (rc *DefaultReconcileHelper) ForceRequeueAfter() time.Duration
- func (rc *DefaultReconcileHelper) PodExec(pod *corev1.Pod, container string, command []string, opts ExecOptions) error
- func (rc *DefaultReconcileHelper) ResetForceRequeueAfter(d time.Duration)
- func (rc *DefaultReconcileHelper) RestConfig() *rest.Config
- func (rc *DefaultReconcileHelper) Scheme() *runtime.Scheme
- type ExecOptions
- type ExecuteFunc
- type Executor
- type ExecutorOption
- type Flow
- type ReconcileContext
- type ReconcileHelper
- type ReconcilePodExecCommandHelper
- type Step
- type Task
Constants ¶
This section is empty.
Variables ¶
var Requeue = Retry
Requeue equivalent to Retry.
var RequeueAfter = RetryAfter
RequeueAfter equivalent to RetryAfter
Functions ¶
Types ¶
type BaseReconcileContext ¶
type BaseReconcileContext struct { ReconcileHelper // contains filtered or unexported fields }
func NewBaseReconcileContext ¶
func NewBaseReconcileContext(h ReconcileHelper, context context.Context, request reconcile.Request, owner client.FieldOwner, recorder record.EventRecorder) *BaseReconcileContext
func (*BaseReconcileContext) Apply ¶
func (rc *BaseReconcileContext) Apply(object client.Object) error
apply sends an apply patch to object's endpoint in the Kubernetes API and updates object with any returned content. The fieldManager is set to r.Owner and the force parameter is true. - https://docs.k8s.io/reference/using-api/server-side-apply/#managers - https://docs.k8s.io/reference/using-api/server-side-apply/#conflicts
func (*BaseReconcileContext) Close ¶
func (rc *BaseReconcileContext) Close() error
func (*BaseReconcileContext) Context ¶
func (rc *BaseReconcileContext) Context() context.Context
func (*BaseReconcileContext) List ¶
func (rc *BaseReconcileContext) List(list client.ObjectList, selector labels.Selector) error
func (*BaseReconcileContext) Name ¶
func (rc *BaseReconcileContext) Name() string
func (*BaseReconcileContext) Namespace ¶
func (rc *BaseReconcileContext) Namespace() string
func (*BaseReconcileContext) Owner ¶
func (rc *BaseReconcileContext) Owner() client.FieldOwner
func (*BaseReconcileContext) Patch ¶
func (rc *BaseReconcileContext) Patch(object client.Object, patch client.Patch, options ...client.PatchOption, ) error
Patch sends patch to object's endpoint in the Kubernetes API and updates object with any returned content. The fieldManager is set to r.Owner, but can be overridden in options. - https://docs.k8s.io/reference/using-api/server-side-apply/#managers
func (*BaseReconcileContext) Recorder ¶
func (rc *BaseReconcileContext) Recorder() record.EventRecorder
func (*BaseReconcileContext) Request ¶
func (rc *BaseReconcileContext) Request() reconcile.Request
type BindFunc ¶
func CombineBinders ¶
func NewStepBinder ¶
func NewStepIfBinder ¶
func ScheduleAfter ¶
type Condition ¶
type Condition interface { Name() string Evaluate(rc ReconcileContext, log logr.Logger) (bool, error) }
func NewCachedCondition ¶
NewCachedCondition returns a condition which evaluates only once and caches the result. Note the error will be returned only when the first time the Evaluate method is invoked. Any sequential calls return the result with a nil error.
func NewCondition ¶
func NewCondition(name string, f ConditionFunc) Condition
type ConditionFunc ¶
type ConditionFunc func(rc ReconcileContext, log logr.Logger) (bool, error)
type DefaultReconcileHelper ¶
type DefaultReconcileHelper struct {
// contains filtered or unexported fields
}
func NewDefaultReconcileHelper ¶
func NewDefaultReconcileHelper( client client.Client, restConfig *rest.Config, clientSet *kubernetes.Clientset, scheme *runtime.Scheme, ) *DefaultReconcileHelper
func NewDefaultReconcileHelperWithManager ¶
func NewDefaultReconcileHelperWithManager(mgr manager.Manager) (helper *DefaultReconcileHelper, err error)
func (*DefaultReconcileHelper) Client ¶
func (rc *DefaultReconcileHelper) Client() client.Client
func (*DefaultReconcileHelper) ClientSet ¶
func (rc *DefaultReconcileHelper) ClientSet() *kubernetes.Clientset
func (*DefaultReconcileHelper) Debug ¶
func (rc *DefaultReconcileHelper) Debug() bool
func (*DefaultReconcileHelper) ForceRequeueAfter ¶
func (rc *DefaultReconcileHelper) ForceRequeueAfter() time.Duration
func (*DefaultReconcileHelper) PodExec ¶
func (rc *DefaultReconcileHelper) PodExec(pod *corev1.Pod, container string, command []string, opts ExecOptions) error
func (*DefaultReconcileHelper) ResetForceRequeueAfter ¶
func (rc *DefaultReconcileHelper) ResetForceRequeueAfter(d time.Duration)
func (*DefaultReconcileHelper) RestConfig ¶
func (rc *DefaultReconcileHelper) RestConfig() *rest.Config
func (*DefaultReconcileHelper) Scheme ¶
func (rc *DefaultReconcileHelper) Scheme() *runtime.Scheme
type ExecOptions ¶
type ExecuteFunc ¶
type ExecuteFunc = func(rc ReconcileContext, flow Flow) (reconcile.Result, error)
type Executor ¶
type Executor interface {
Execute(rc ReconcileContext, task *Task) (reconcile.Result, error)
}
func NewExecutor ¶
func NewExecutor(logger logr.Logger, opts ...ExecutorOption) Executor
type ExecutorOption ¶
type ExecutorOption func(e *executor)
type Flow ¶
type Flow interface { // Logger returns the logger Logger() logr.Logger // RetryAfter requeue the reconcile request after given duration and log the message and key-values. RetryAfter(duration time.Duration, msg string, kvs ...interface{}) (reconcile.Result, error) // Retry the reconcile request immediately and log the message and key-values. Retry(msg string, kvs ...interface{}) (reconcile.Result, error) // Continue the steps and log the message and key-values. Continue(msg string, kvs ...interface{}) (reconcile.Result, error) // Pass continues the steps without any logs. Pass() (reconcile.Result, error) // Wait breaks the current reconcile and wait for another reconcile request, and log the message and key-values. Wait(msg string, kvs ...interface{}) (reconcile.Result, error) // Break is same as Wait. Break(msg string, kvs ...interface{}) (reconcile.Result, error) // Error breaks the current reconcile with error and log the message and key-values. Error(err error, msg string, kvs ...interface{}) (reconcile.Result, error) // RetryErr is like Error but without returning error to the controller framework, but // give it a chance to retry later. Default retry period is 1s. RetryErr(err error, msg string, kvs ...interface{}) (reconcile.Result, error) // WithLogger return a flow binding to the old but with a new logger. WithLogger(log logr.Logger) Flow // WithLoggerValues returns a flow binding to the old but logs with extra values. WithLoggerValues(keyAndValues ...interface{}) Flow }
Flow is a helper interface to interact with current reconcile loop and providing a logger method to get current logger (with some attached key-values).
type ReconcileContext ¶
type ReconcileContext interface { ReconcileHelper // Name is a helper method that returns the name of current reconcile object. Name() string // Namespace is a helper method that returns the namespace of current reconcile object. Namespace() string // Context returns the current reconcile context. Context() context.Context // Request returns the current reconcile request. Request() reconcile.Request // Owner returns the current reconcile fieldOwner. Owner() client.FieldOwner // Recorder returns the current reconcile recorder. Recorder() record.EventRecorder Get(object client.Object) error List(list client.ObjectList, selector labels.Selector) error Patch(object client.Object, patch client.Patch, options ...client.PatchOption) error Apply(object client.Object) error // Server-Side Apply CSAApply(new client.Object, old ...client.Object) error // Client-Side Apply Close() error }
ReconcileContext declares the context for reconciliation.
type ReconcileHelper ¶
type ReconcileHelper interface { ReconcilePodExecCommandHelper Debug() bool ForceRequeueAfter() time.Duration ResetForceRequeueAfter(d time.Duration) // Client returns a API client of k8s. Client() client.Client // RestConfig returns the rest config used by client. RestConfig() *rest.Config // ClientSet returns the client set. ClientSet() *kubernetes.Clientset // Scheme returns the currently using scheme. Scheme() *runtime.Scheme }
ReconcileHelper declares the reconcile helper.
type Step ¶
type Step interface { Name() string Execute(rc ReconcileContext, flow Flow) (reconcile.Result, error) }
func NewStep ¶
func NewStep(name string, f ExecuteFunc) Step