Documentation ¶
Index ¶
- Variables
- func Debug(e *executor)
- type BaseReconcileContext
- func (rc *BaseReconcileContext) Client() client.Client
- func (rc *BaseReconcileContext) ClientSet() *kubernetes.Clientset
- func (rc *BaseReconcileContext) Close() error
- func (rc *BaseReconcileContext) Context() context.Context
- func (rc *BaseReconcileContext) Debug() bool
- func (rc *BaseReconcileContext) ExecuteCommandOn(pod *corev1.Pod, container string, command []string, opts ExecOptions) error
- func (rc *BaseReconcileContext) ForceRequeueAfter() time.Duration
- func (rc *BaseReconcileContext) GetCrd(apiVersion, kind string) (*apiextensionsv1.CustomResourceDefinition, error)
- func (rc *BaseReconcileContext) Name() string
- func (rc *BaseReconcileContext) NameInto(f func(name string) string) string
- func (rc *BaseReconcileContext) Namespace() string
- func (rc *BaseReconcileContext) NamespacedNameInto(f func(name string) string) types.NamespacedName
- func (rc *BaseReconcileContext) Request() reconcile.Request
- func (rc *BaseReconcileContext) ResetForceRequeueAfter(d time.Duration)
- func (rc *BaseReconcileContext) RestConfig() *rest.Config
- func (rc *BaseReconcileContext) Scheme() *runtime.Scheme
- 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 ExecOptions
- type ExecuteFunc
- type Executor
- type ExecutorOption
- type Flow
- type ReconcileContext
- type ReconcileControl
- type ReconcileCustomResourceDefinitionHelper
- type ReconcileOptions
- type ReconcileRemoteCommandHelper
- type ReconcileRequestHelper
- type Step
- type Task
Constants ¶
This section is empty.
Variables ¶
View Source
var Requeue = Retry
Requeue equivalent to Retry.
View Source
var RequeueAfter = RetryAfter
RequeueAfter equivalent to RetryAfter
Functions ¶
Types ¶
type BaseReconcileContext ¶
type BaseReconcileContext struct {
// contains filtered or unexported fields
}
func NewBaseReconcileContext ¶
func NewBaseReconcileContextFrom ¶
func NewBaseReconcileContextFrom(base *BaseReconcileContext, context context.Context, request reconcile.Request) *BaseReconcileContext
func (*BaseReconcileContext) Client ¶
func (rc *BaseReconcileContext) Client() client.Client
func (*BaseReconcileContext) ClientSet ¶
func (rc *BaseReconcileContext) ClientSet() *kubernetes.Clientset
func (*BaseReconcileContext) Close ¶
func (rc *BaseReconcileContext) Close() error
func (*BaseReconcileContext) Context ¶
func (rc *BaseReconcileContext) Context() context.Context
func (*BaseReconcileContext) Debug ¶
func (rc *BaseReconcileContext) Debug() bool
func (*BaseReconcileContext) ExecuteCommandOn ¶
func (rc *BaseReconcileContext) ExecuteCommandOn(pod *corev1.Pod, container string, command []string, opts ExecOptions) error
func (*BaseReconcileContext) ForceRequeueAfter ¶
func (rc *BaseReconcileContext) ForceRequeueAfter() time.Duration
func (*BaseReconcileContext) GetCrd ¶
func (rc *BaseReconcileContext) GetCrd(apiVersion, kind string) (*apiextensionsv1.CustomResourceDefinition, error)
func (*BaseReconcileContext) Name ¶
func (rc *BaseReconcileContext) Name() string
func (*BaseReconcileContext) NameInto ¶
func (rc *BaseReconcileContext) NameInto(f func(name string) string) string
func (*BaseReconcileContext) Namespace ¶
func (rc *BaseReconcileContext) Namespace() string
func (*BaseReconcileContext) NamespacedNameInto ¶
func (rc *BaseReconcileContext) NamespacedNameInto(f func(name string) string) types.NamespacedName
func (*BaseReconcileContext) Request ¶
func (rc *BaseReconcileContext) Request() reconcile.Request
func (*BaseReconcileContext) ResetForceRequeueAfter ¶
func (rc *BaseReconcileContext) ResetForceRequeueAfter(d time.Duration)
func (*BaseReconcileContext) RestConfig ¶
func (rc *BaseReconcileContext) RestConfig() *rest.Config
func (*BaseReconcileContext) Scheme ¶
func (rc *BaseReconcileContext) Scheme() *runtime.Scheme
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 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 { ReconcileOptions ReconcileControl ReconcileRemoteCommandHelper ReconcileRequestHelper ReconcileCustomResourceDefinitionHelper // 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 // Context returns the current reconcile context. Context() context.Context // Request returns the current reconcile request. Request() reconcile.Request // Close closes the context to avoid resource leaks. Close() error }
ReconcileContext declares the context for reconciliation.
type ReconcileControl ¶
type ReconcileCustomResourceDefinitionHelper ¶
type ReconcileCustomResourceDefinitionHelper interface { // GetCrd queries the api server and get the target custom resource definition if found. GetCrd(apiVersion, kind string) (*apiextensionsv1.CustomResourceDefinition, error) }
type ReconcileOptions ¶
type ReconcileOptions interface {
Debug() bool
}
type ReconcileRequestHelper ¶
type ReconcileRequestHelper interface { // 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 // NameInto is a helper method that returns a string like "f({name})" where name is // the name of current reconcile object. NameInto(f func(name string) string) string // NamespacedNameInto is a helper method that returns a namespaced name like "{namespace}/f({name})" // where "{namespace}/{name}" is of the current reconcile object. NamespacedNameInto(f func(name string) string) types.NamespacedName }
type Step ¶
type Step interface { Name() string Execute(rc ReconcileContext, flow Flow) (reconcile.Result, error) }
func NewStep ¶
func NewStep(name string, f ExecuteFunc) Step
Source Files ¶
Click to show internal directories.
Click to hide internal directories.