clienttest

package
v0.0.0-...-873615e Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeCRDWithAnnotations

func MakeCRDWithAnnotations(t test.Failer, c kube.Client, g schema.GroupVersionResource, annotations map[string]string)

func Names

func Names[T controllers.Object](list []T) sets.String

func TrackerHandler

func TrackerHandler(tracker *assert.Tracker[string]) controllers.EventHandler[controllers.Object]

TrackerHandler returns an object handler that records each event

Types

type TestClient

type TestClient[T controllers.Object] struct {
	TestWriter[T]
	// contains filtered or unexported fields
}

func NewDirectClient

func NewDirectClient[T controllers.ComparableObject, PT any, TL runtime.Object](t test.Failer, c kube.Client) TestClient[T]

NewDirectClient returns a new client for the given type. Reads are directly to the API server. Any errors will call t.Fatal. Typically, clienttest.WrapReadWriter should be used to simply wrap an existing client when testing an informer. However, NewDirectClient can be useful if we do not need/want an informer and need direct reads. Generic parameters represent the type with and without a pointer, and the list type. Example: NewDirectClient[*Pod, Pod, *PodList] Istio types use a non-standard pointer type for lists. As a result, you need to set the pointer type twice. Example: NewDirectClient[*ServiceEntry, *ServiceEntry, *ServiceEntryList](t, kc)

func Wrap

Wrap returns a client that calls t.Fatal on errors. Reads may be cached or uncached, depending on the input client. Note: this is identical to WrapReadWriter but works around Go limitations, allowing calling w/o specifying generic parameters in the common case.

func WrapReadWriter

func WrapReadWriter[T controllers.Object](t test.Failer, c kclient.ReadWriter[T]) TestClient[T]

WrapReadWriter returns a client that calls t.Fatal on errors. Reads may be cached or uncached, depending on the input client.

func (TestClient[T]) Get

func (t TestClient[T]) Get(name, namespace string) T

func (TestClient[T]) List

func (t TestClient[T]) List(namespace string, selector klabels.Selector) []T

type TestWriter

type TestWriter[T controllers.Object] struct {
	// contains filtered or unexported fields
}

func NewWriter

NewWriter returns a new client for the given type. Any errors will call t.Fatal.

func (TestWriter[T]) Create

func (t TestWriter[T]) Create(object T) T

func (TestWriter[T]) CreateOrUpdate

func (t TestWriter[T]) CreateOrUpdate(object T) T

func (TestWriter[T]) CreateOrUpdateStatus

func (t TestWriter[T]) CreateOrUpdateStatus(object T) T

func (TestWriter[T]) Delete

func (t TestWriter[T]) Delete(name, namespace string)

func (TestWriter[T]) Update

func (t TestWriter[T]) Update(object T) T

func (TestWriter[T]) UpdateStatus

func (t TestWriter[T]) UpdateStatus(object T) T

Jump to

Keyboard shortcuts

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