wait

package
v0.0.0-...-d62d56f Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: Apache-2.0 Imports: 2 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TimeoutError         = "timeout waiting on condition"
	WatchConnectionError = "error with watch connection"
)

Functions

func WatchWait

func WatchWait(watchInterface watch.Interface, check WatchCheckFunc) error

WatchWait uses the `watchInterface` to wait until the `check` function to returns true. e.g. WatchWait for provisioning a cluster

 result, err := r.client.Provisioning.Clusters(namespace).Watch(context.TODO(), metav1.ListOptions{
		FieldSelector:  "metadata.name=" + clusterName,
		TimeoutSeconds: &defaults.WatchTimeoutSeconds,
 })
 require.NoError(r.T(), err)
 err = wait.WatchWait(result, checkFunc)

Types

type WatchCheckFunc

type WatchCheckFunc func(watch.Event) (bool, error)

WatchCheckFunc is the function type of `check` needed for WatchWait e.g.

 checkFunc := func(event watch.Event) (ready bool, err error) {
		cluster := event.Object.(*apisV1.Cluster)
		ready = cluster.Status.Ready
		return ready, nil
 }

Jump to

Keyboard shortcuts

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