utils

package
v0.23.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EmptyEtcdPartialObjectMetadata

func EmptyEtcdPartialObjectMetadata() *metav1.PartialObjectMetadata

EmptyEtcdPartialObjectMetadata creates an empty PartialObjectMetadata for an Etcd object.

func MustBeGreaterThan

func MustBeGreaterThan[E constraints.Ordered](key string, lowerBound, value E) error

MustBeGreaterThan checks if the value is greater than the lowerBound. If it is not then an error is returned else nil is returned. Type is constrained by constraints.Ordered which enforces the consumers to use concrete types that can be compared using >, >=, <, <= operators.

func MustBeGreaterThanOrEqualTo

func MustBeGreaterThanOrEqualTo[E constraints.Ordered](key string, lowerBound, value E) error

MustBeGreaterThanOrEqualTo checks if the value is greater than or equal to the lowerBound. If it is not then an error is returned else nil is returned. Type is constrained by constraints.Ordered which enforces the consumers to use concrete types that can be compared using >, >=, <, <= operators.

func ShortCircuitReconcileFlow

func ShortCircuitReconcileFlow(result ReconcileStepResult) bool

ShortCircuitReconcileFlow indicates whether to short-circuit the reconciliation.

func ShouldBeOneOfAllowedValues

func ShouldBeOneOfAllowedValues[E comparable](key string, allowedValues []E, value E) error

ShouldBeOneOfAllowedValues checks if value is amongst the allowedValues. If it is not then an error is returned else nil is returned. Type is constrained by comparable forcing the consumers to only use concrete types that can be compared using the == or != operators.

Types

type LastOperationAndLastErrorsRecorder

type LastOperationAndLastErrorsRecorder interface {
	// RecordStart records the start of an operation in the Etcd status.
	RecordStart(ctx component.OperatorContext, etcdObjectKey client.ObjectKey, operationType druidv1alpha1.LastOperationType) error
	// RecordSuccess records the success of an operation in the Etcd status.
	RecordSuccess(ctx component.OperatorContext, etcdObjectKey client.ObjectKey, operationType druidv1alpha1.LastOperationType) error
	// RecordErrors records errors encountered in the last operation in the Etcd status.
	RecordErrors(ctx component.OperatorContext, etcdObjectKey client.ObjectKey, operationType druidv1alpha1.LastOperationType, description string, errs ...error) error
}

LastOperationAndLastErrorsRecorder records etcd.Status.LastOperation and etcd.Status.LastErrors.

func NewLastOperationAndLastErrorsRecorder

func NewLastOperationAndLastErrorsRecorder(client client.Client, logger logr.Logger) LastOperationAndLastErrorsRecorder

NewLastOperationAndLastErrorsRecorder returns a new LastOperationAndLastErrorsRecorder.

type ReconcileStepResult

type ReconcileStepResult struct {
	// contains filtered or unexported fields
}

ReconcileStepResult holds the result of a reconcile step.

func ContinueReconcile

func ContinueReconcile() ReconcileStepResult

ContinueReconcile returns a ReconcileStepResult that continues the reconciliation.

func DoNotRequeue

func DoNotRequeue() ReconcileStepResult

DoNotRequeue returns a ReconcileStepResult that does not requeue the reconciliation.

func GetLatestEtcd

func GetLatestEtcd(ctx context.Context, client client.Client, objectKey client.ObjectKey, etcd *druidv1alpha1.Etcd) ReconcileStepResult

GetLatestEtcd returns the latest version of the Etcd object.

func GetLatestEtcdPartialObjectMeta

func GetLatestEtcdPartialObjectMeta(ctx context.Context, client client.Client, objectKey client.ObjectKey, etcdObjMetadata *metav1.PartialObjectMetadata) ReconcileStepResult

GetLatestEtcdPartialObjectMeta returns the latest version of the Etcd object metadata.

func ReconcileAfter

func ReconcileAfter(period time.Duration, description string) ReconcileStepResult

ReconcileAfter returns a ReconcileStepResult that requeues the reconciliation after the given period.

func ReconcileWithError

func ReconcileWithError(errs ...error) ReconcileStepResult

ReconcileWithError returns a ReconcileStepResult with the given errors.

func ReconcileWithErrorAfter

func ReconcileWithErrorAfter(period time.Duration, errs ...error) ReconcileStepResult

ReconcileWithErrorAfter returns a ReconcileStepResult that requeues the reconciliation after the given period with the given errors.

func (ReconcileStepResult) GetCombinedError

func (r ReconcileStepResult) GetCombinedError() error

GetCombinedError returns the combined error from the reconcile step.

func (ReconcileStepResult) GetDescription

func (r ReconcileStepResult) GetDescription() string

GetDescription returns the description of the reconcile step.

func (ReconcileStepResult) GetErrors

func (r ReconcileStepResult) GetErrors() []error

GetErrors returns the errors from the reconcile step.

func (ReconcileStepResult) GetResult

func (r ReconcileStepResult) GetResult() ctrl.Result

GetResult returns the result from the reconcile step.

func (ReconcileStepResult) HasErrors

func (r ReconcileStepResult) HasErrors() bool

HasErrors returns true if there are errors from the reconcile step.

func (ReconcileStepResult) NeedsRequeue

func (r ReconcileStepResult) NeedsRequeue() bool

NeedsRequeue returns true if reconciler should requeue the request.

func (ReconcileStepResult) ReconcileResult

func (r ReconcileStepResult) ReconcileResult() (ctrl.Result, error)

ReconcileResult returns the result and error from the reconcile step.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL