fakeclient

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: Apache-2.0 Imports: 17 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Objects       map[StorageKey]runtime.Object
	ErrorInjector ErrorInjector
}

Client Objects mocks k8s resources ErrorInjector is used to force errors from controller for test refer steps.go in int-test folder

func NewFakeClient

func NewFakeClient(initialObjects []runtime.Object, errorInjector ErrorInjector) (*Client, error)

NewFakeClient create fake client

func (Client) Create

func (f Client) Create(_ context.Context, obj client.Object, _ ...client.CreateOption) error

Create fake object

func (Client) Delete

func (f Client) Delete(ctx context.Context, obj client.Object, opts ...client.DeleteOption) error

Delete fake object

func (Client) DeleteAllOf

func (f Client) DeleteAllOf(_ context.Context, _ client.Object, _ ...client.DeleteAllOfOption) error

DeleteAllOf delete all objects

func (Client) Get

func (f Client) Get(_ context.Context, key client.ObjectKey, obj client.Object) error

Get fake object

func (Client) List

func (f Client) List(_ context.Context, list client.ObjectList, opts ...client.ListOption) error

List fake objects

func (Client) Patch

Patch fake object

func (Client) RESTMapper

func (f Client) RESTMapper() meta.RESTMapper

RESTMapper for client

func (Client) Scheme

func (f Client) Scheme() *runtime.Scheme

Scheme of client

func (Client) SetDeletionTimeStamp

func (f Client) SetDeletionTimeStamp(_ context.Context, obj client.Object) error

SetDeletionTimeStamp set deletion timestamp so that reconcile can go into deletion part of code

func (Client) Status

func (f Client) Status() client.StatusWriter

Status of client

func (Client) Update

func (f Client) Update(_ context.Context, obj client.Object, _ ...client.UpdateOption) error

Update fake object

type ErrorInjector

type ErrorInjector interface {
	ShouldFail(method string, obj runtime.Object) error
}

ErrorInjector to force error

type MockUtils

type MockUtils struct {
	// FakeClient client
	FakeClient *Client
	// Specs client.WithWatch
	Specs common.Common
}

MockUtils fake struct

type StorageKey

type StorageKey struct {
	Namespace string
	Name      string
	Kind      string
}

StorageKey metadata of object to store

Jump to

Keyboard shortcuts

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