wait

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: Apache-2.0 Imports: 15 Imported by: 4

Documentation

Index

Constants

View Source
const (
	WaiterDefaultTimeout  = 60 * time.Second
	WaiterDefaultInterval = time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option interface {
	ApplyToWaiterConfig(c *WaiterConfig)
}

type TypeWaitFn

type TypeWaitFn func(ctx context.Context, w *Waiter, object client.Object, opts ...Option) error

type UnknownTypeError

type UnknownTypeError struct {
	GVK schema.GroupVersionKind
}

UnknownTypeError is returned when the given GroupKind is not registered.

func (*UnknownTypeError) Error

func (e *UnknownTypeError) Error() string

type Waiter

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

Waiter implements functions to block till kube objects are in a certain state.

func NewWaiter

func NewWaiter(
	client client.Client, scheme *runtime.Scheme,
	defaultOpts ...Option,
) *Waiter

Creates a new Waiter instance.

func (*Waiter) WaitForCondition

func (w *Waiter) WaitForCondition(
	ctx context.Context, object client.Object,
	conditionType string, conditionStatus metav1.ConditionStatus,
	opts ...Option,
) error

Waits for an object to report the given condition with given status. Takes observedGeneration into account when present on the object. observedGeneration may be reported on the condition or under .status.observedGeneration.

func (*Waiter) WaitForObject

func (w *Waiter) WaitForObject(
	ctx context.Context, object client.Object, waitReason string,
	checkFn func(obj client.Object) (done bool, err error),
	opts ...Option,
) error

Wait for an object to match a check function.

func (*Waiter) WaitForReadiness

func (w *Waiter) WaitForReadiness(
	ctx context.Context, object client.Object, opts ...Option,
) error

Waits for an object to be considered available.

func (*Waiter) WaitToBeGone

func (w *Waiter) WaitToBeGone(
	ctx context.Context, object client.Object,
	checkFn func(obj client.Object) (done bool, err error),
	opts ...Option,
) error

Wait for an object to not exist anymore.

type WaiterConfig

type WaiterConfig struct {
	Timeout    time.Duration
	Interval   time.Duration
	KnownTypes map[schema.GroupVersionKind]TypeWaitFn
}

func (*WaiterConfig) Default

func (c *WaiterConfig) Default()

Sets defaults on the waiter config.

type WithInterval

type WithInterval time.Duration

func (WithInterval) ApplyToWaiterConfig

func (i WithInterval) ApplyToWaiterConfig(c *WaiterConfig)

type WithTimeout

type WithTimeout time.Duration

func (WithTimeout) ApplyToWaiterConfig

func (t WithTimeout) ApplyToWaiterConfig(c *WaiterConfig)

type WithTypeWaitFunctions

type WithTypeWaitFunctions map[schema.GroupVersionKind]TypeWaitFn

func (WithTypeWaitFunctions) ApplyToWaiterConfig

func (fn WithTypeWaitFunctions) ApplyToWaiterConfig(c *WaiterConfig)

Jump to

Keyboard shortcuts

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