watch

package
v0.0.0-...-a605f52 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WaitForCacheSyncWithTimeout

func WaitForCacheSyncWithTimeout(w Watch, d time.Duration) error

WaitForCacheSyncWithTimeout waits for all the caches to sync. Returns false if it could not sync a informer.

Types

type EventBus

type EventBus interface {
	// Start starts watcher and its informer
	Start(<-chan struct{}) error
	// Subscribe registers a subscription to receive vents published for a specific key.
	Subscribe(key string, ch TestrunChannel) EventBusHandle
	// Unsubscribe removes the subscription from a key with the unique handle.
	Unsubscribe(key string, h EventBusHandle)
	// Publish sends a update to all registered subscription for the specific key.
	Publish(key string, tr *tmv1beta1.Testrun)
	// Has checks if the given is subscribed by anyone.
	Has(key string) bool
	// Subscriptions returns a list of all watched keys.
	Subscriptions() []string
}

func NewEventBus

func NewEventBus(log logr.Logger) EventBus

type EventBusHandle

type EventBusHandle *int

type Informer

type Informer interface {
	// Start starts watcher and its informer
	Start(ctx context.Context) error

	// WaitForCacheSync waits for all the caches to sync.  Returns false if it could not sync a informer.
	WaitForCacheSync(ctx context.Context) bool

	// InjectEventBus injects the the event bus instance of the watch
	InjectEventBus(eb EventBus)

	// Client returns the used k8s client.
	Client() client.Client
}

Informer is the internal watch that interacts with the cluster and publishes events to the event bus.

type InformerType

type InformerType string

InformerType is the type of informer to be used.

const CachedInformerType InformerType = "cached"

CachedInformerType specifies the cached informer type.

const PollingInformerType InformerType = "polling"

PollingInformerType specifies the polling informer type.

type Options

type Options struct {
	// Scheme is the scheme
	Scheme *runtime.Scheme

	// InformerType is the type of the informer that should be used.
	InformerType InformerType

	// SyncPeriod is the minimum time where resources are reconciled
	// Only relevant if the cached informer should be used
	SyncPeriod *time.Duration

	// PollInterval is the time where informer polls the apiserver for an update.
	// Only relevant if the polling informer is used.
	PollInterval *time.Duration

	// Namespace restrict the namespace to watch.
	// Leave this value empty to watch all namespaces.
	Namespace string
}

type TestrunChannel

type TestrunChannel chan *tmv1beta1.Testrun

type Watch

type Watch interface {
	// Watch registers a watch for a testrun resource until the testrun is completed
	Watch(namespace, name string, f WatchFunc) error

	WatchUntil(timeout time.Duration, namespace, name string, f WatchFunc) error

	Client() client.Client

	// Start starts watcher and its informer
	Start(ctx context.Context) error

	// WaitForCacheSync waits for all the caches to sync.  Returns false if it could not sync a informer.
	WaitForCacheSync(ctx context.Context) bool
}

func New

func New(log logr.Logger, config *rest.Config, options *Options) (Watch, error)

New creates a new watch client

func NewFromFile

func NewFromFile(log logr.Logger, kubeconfig string, options *Options) (Watch, error)

NewFromFile creates a new watch client from a kubeconfig file

type WatchFunc

type WatchFunc func(*tmv1beta1.Testrun) (bool, error)

Jump to

Keyboard shortcuts

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