Documentation
¶
Index ¶
- func RecordContextualError(ctx context.Context, recorder kuberecorder.EventRecorder, obj client.Object, ...)
- func RecordReconcileReq(ctx context.Context, recorder kuberecorder.EventRecorder, obj client.Object, ...)
- type Conditions
- type Helper
- type HelperOptions
- type Option
- func WithConditions(condns ...Conditions) Option
- func WithIgnoreNotFound() Option
- func WithPatchFieldOwner(fieldOwner string) Option
- func WithProcessors(rps ...ResultProcessor) Option
- func WithReconcileError(re error) Option
- func WithReconcileResult(rr reconcile.Result) Option
- func WithResultBuilder(rb reconcile.RuntimeResultBuilder) Option
- type ResultProcessor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RecordContextualError ¶
func RecordContextualError(ctx context.Context, recorder kuberecorder.EventRecorder, obj client.Object, _ reconcile.Result, err error)
RecordContextualError is a ResultProcessor that records the contextual errors based on their types. An event is recorded for the errors that are returned to the runtime. The runtime handles the logging of the error. An event is recorded and an error is logged for errors that are known to be swallowed, not returned to the runtime.
func RecordReconcileReq ¶
func RecordReconcileReq(ctx context.Context, recorder kuberecorder.EventRecorder, obj client.Object, _ reconcile.Result, _ error)
RecordReconcileReq is a ResultProcessor that checks the reconcile annotation value and sets it in the object status as status.lastHandledReconcileAt.
Types ¶
type Conditions ¶
type Conditions struct { // Target is the target condition, e.g.: Ready. Target string // Owned conditions are the conditions owned by the reconciler for this // target condition. Owned []string // Summarize conditions are the conditions that the target condition depends // on. Summarize []string // NegativePolarity conditions are the conditions in Summarize with negative // polarity. NegativePolarity []string }
Conditions contains all the conditions information needed to summarize the target condition.
type Helper ¶
type Helper struct {
// contains filtered or unexported fields
}
Helper is SummarizeAndPatch helper.
func NewHelper ¶
func NewHelper(recorder kuberecorder.EventRecorder, patchHelper *patch.Helper) *Helper
NewHelper returns an initialized Helper.
func (*Helper) SummarizeAndPatch ¶
func (h *Helper) SummarizeAndPatch(ctx context.Context, obj conditions.Setter, options ...Option) (ctrl.Result, error)
SummarizeAndPatch summarizes and patches the result to the target object. When used at the very end of a reconciliation, the result builder must be specified using the Option WithResultBuilder(). The returned result and error can be returned as the return values of the reconciliation. When used in the middle of a reconciliation, no result builder should be set and the result can be ignored.
type HelperOptions ¶
type HelperOptions struct { // Conditions are conditions that needs to be summarized and persisted on // the object. Conditions []Conditions // Processors are chain of ResultProcessors for processing the results. This // can be used to analyze and modify the results. This enables injecting // custom middlewares in the SummarizeAndPatch operation. Processors []ResultProcessor // IgnoreNotFound can be used to ignores any resource not found error during // patching. IgnoreNotFound bool // ReconcileResult is the abstracted result of reconciliation. ReconcileResult reconcile.Result // ReconcileError is the reconciliation error. ReconcileError error // ResultBuilder defines how the reconciliation result is computed. ResultBuilder reconcile.RuntimeResultBuilder // PatchFieldOwner defines the field owner configuration for the Kubernetes // patch operation. PatchFieldOwner string }
HelperOptions contains options for SummarizeAndPatch. Summarizing and patching at the very end of a reconciliation involves computing the result of the reconciler. This requires providing the ReconcileResult, ReconcileError and a ResultBuilder in the context of the reconciliation. For using this to perform intermediate patching in the middle of a reconciliation, no ReconcileResult, ReconcileError or ResultBuilder should be provided. Only Conditions summary would be calculated and patched.
type Option ¶
type Option func(*HelperOptions)
Option is configuration that modifies SummarizeAndPatch.
func WithConditions ¶
func WithConditions(condns ...Conditions) Option
WithConditions sets the Conditions for which summary is calculated in SummarizeAndPatch.
func WithIgnoreNotFound ¶
func WithIgnoreNotFound() Option
WithIgnoreNotFound skips any resource not found error during patching.
func WithPatchFieldOwner ¶
WithPatchFieldOwner sets the FieldOwner in the patch helper.
func WithProcessors ¶
func WithProcessors(rps ...ResultProcessor) Option
WithProcessors can be used to inject middlewares in the SummarizeAndPatch process, to be executed before the result calculation and patching.
func WithReconcileError ¶
WithReconcileError sets the value of input error used to calculate the results reconciliation in SummarizeAndPatch.
func WithReconcileResult ¶
WithReconcileResult sets the value of input result used to calculate the results of reconciliation in SummarizeAndPatch.
func WithResultBuilder ¶
func WithResultBuilder(rb reconcile.RuntimeResultBuilder) Option
WithResultBuilder sets the strategy for result computation in SummarizeAndPatch.
type ResultProcessor ¶
type ResultProcessor func(context.Context, kuberecorder.EventRecorder, client.Object, reconcile.Result, error)
ResultProcessor processes the results of reconciliation (the object, result and error). Any errors during processing need not result in the reconciliation failure. The errors can be recorded as logs and events.