testwatch

package
v1.22.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WatchObject

func WatchObject(ctx context.Context, c client.WithWatch, exampleObjList client.ObjectList) (watch.Interface, error)

WatchObject returns a new watcher for a typed resource. The watcher will automatically be stopped when the Context is done.

This is designed for simplified use in tests and is not likely to be suitable for non-test usage.

func WatchObjectUntil

func WatchObjectUntil(ctx context.Context, scheme *runtime.Scheme, watcher watch.Interface, key client.ObjectKey, condition func(watch.Event) error) error

WatchObjectUntil consumes a watcher, filters events to just those for the specified object (by key), and tests each event using the specified condition function. If the condition function returns an error, the watcher will cache the error and continue. If the condition returns nil, the watcher will be stopped and WatchObjectUntil will return nil. If the watcher is stopped, before the condition is met, WatchObjectUntil will return the last cached error from the condition function. WatchObjectUntil also logs object diffs for each event, to facilitate debugging.

This is designed for simplified use in tests and is not likely to be suitable for non-test usage.

func WatchUnstructured

WatchUnstructured returns a new watcher for a dynamic (Unstructured) resource. The watcher will automatically be stopped when the Context is done.

This is designed for simplified use in tests and is not likely to be suitable for non-test usage.

Types

type TerminalError

type TerminalError struct {
	Cause error
}

TerminalError will stop WatchObjectUntil if returned by the condition function.

func NewTerminalError

func NewTerminalError(cause error) *TerminalError

NewTerminalError constructs a new TerminalError

func (*TerminalError) Error

func (te *TerminalError) Error() string

Error returns the error message

func (*TerminalError) Unwrap

func (te *TerminalError) Unwrap() error

Unwrap returns the cause of this TerminalError

Jump to

Keyboard shortcuts

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