client

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package client provides a mock Kubernetes client for use in testing controllers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockClient

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

MockClient provides a mock Kubernetes client.

func NewMockClient added in v1.10.0

func NewMockClient(scheme *runtime.Scheme, hooks ...func(_ context.Context, client *MockClient, object ctrlClient.Object) error) *MockClient

NewMockClient creates a new MockClient.

func NewMockClientWithHooks added in v1.12.0

func NewMockClientWithHooks(scheme *runtime.Scheme, createHooks []func(ctx context.Context, client *MockClient, object ctrlClient.Object) error, updateHooks []func(ctx context.Context, client *MockClient, object ctrlClient.Object) error) *MockClient

NewMockClientWithHooks creates a new MockClient with hooks.

func (*MockClient) AnnotatedEventf

func (client *MockClient) AnnotatedEventf(object runtime.Object, annotations map[string]string, eventType string, reason string, messageFormat string, args ...interface{})

AnnotatedEventf is just like eventf, but with annotations attached

func (*MockClient) Clear

func (client *MockClient) Clear()

Clear erases any mock data.

func (*MockClient) Create

func (client *MockClient) Create(ctx context.Context, object ctrlClient.Object, options ...ctrlClient.CreateOption) error

Create creates a new object

func (*MockClient) Delete

func (client *MockClient) Delete(ctx context.Context, object ctrlClient.Object, options ...ctrlClient.DeleteOption) error

Delete deletes an object.

func (*MockClient) DeleteAllOf

func (client *MockClient) DeleteAllOf(ctx context.Context, object ctrlClient.Object, options ...ctrlClient.DeleteAllOfOption) error

DeleteAllOf deletes all objects of the given type matching the given options.

func (*MockClient) Event

func (client *MockClient) Event(object runtime.Object, eventType string, reason string, message string)

Event sends an event

func (*MockClient) Eventf

func (client *MockClient) Eventf(object runtime.Object, eventType string, reason string, messageFormat string, args ...interface{})

Eventf is just like Event, but with Sprintf for the message field.

func (*MockClient) Get

func (client *MockClient) Get(ctx context.Context, key ctrlClient.ObjectKey, object ctrlClient.Object) error

Get retrieves an object.

func (*MockClient) List

func (client *MockClient) List(ctx context.Context, list ctrlClient.ObjectList, options ...ctrlClient.ListOption) error

List lists objects.

func (*MockClient) MockStuckTermination added in v0.31.0

func (client *MockClient) MockStuckTermination(object ctrlClient.Object, terminating bool) error

MockStuckTermination sets a flag determining whether an object should get stuck in terminating when it is deleted.

func (*MockClient) PastEventf

func (client *MockClient) PastEventf(object runtime.Object, timestamp metav1.Time, eventType string, reason string, messageFormat string, args ...interface{})

PastEventf is just like Eventf, but with an option to specify the event's 'timestamp' field.

func (*MockClient) Patch

func (client *MockClient) Patch(ctx context.Context, obj ctrlClient.Object, patch ctrlClient.Patch, options ...ctrlClient.PatchOption) error

Patch patches an object.

func (*MockClient) RESTMapper added in v0.29.0

func (client *MockClient) RESTMapper() meta.RESTMapper

RESTMapper returns the RESTMapper

func (*MockClient) RemovePodIP added in v0.36.0

func (client *MockClient) RemovePodIP(pod *corev1.Pod) error

RemovePodIP sets the IP address of the Pod to an empty string

func (*MockClient) Scheme added in v0.29.0

func (client *MockClient) Scheme() *runtime.Scheme

Scheme returns the runtime Scheme

func (*MockClient) SetPodIntoFailed added in v0.32.0

func (client *MockClient) SetPodIntoFailed(ctx context.Context, object ctrlClient.Object, reason string) error

SetPodIntoFailed sets a Pod into a failed status with the given reason

func (*MockClient) Status

func (client *MockClient) Status() ctrlClient.StatusWriter

Status returns a writer for updating status.

func (*MockClient) Update

func (client *MockClient) Update(ctx context.Context, object ctrlClient.Object, options ...ctrlClient.UpdateOption) error

Update updates an object.

type MockStatusClient

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

MockStatusClient wraps a client to provide specialized operations for updating status.

func (MockStatusClient) Patch

func (client MockStatusClient) Patch(ctx context.Context, object ctrlClient.Object, patch ctrlClient.Patch, options ...ctrlClient.PatchOption) error

Patch patches an object's status. This is not yet implemented.

func (MockStatusClient) Update

func (client MockStatusClient) Update(ctx context.Context, object ctrlClient.Object, options ...ctrlClient.UpdateOption) error

Update updates an object. This does not support the options argument yet.

Jump to

Keyboard shortcuts

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