fake

package
v1.15.1-rc.3 Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 License: Apache-2.0 Imports: 42 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConflictHandler added in v1.15.1

func NewConflictHandler() conflict.Handler

NewConflictHandler initiates a fake implementation of conflict.Handler.

func NewDiscoveryClient

func NewDiscoveryClient(gvks ...schema.GroupVersionKind) discoveryutil.ServerResourcer

NewDiscoveryClient returns a discoveryClient that reports types available to the API Server with no errors

Does not report the scope of each GVK as no tests requiring a discoveryClient use scope information.

func NewDiscoveryClientWithError added in v1.15.1

func NewDiscoveryClientWithError(wantedErr error, gvks ...schema.GroupVersionKind) discoveryutil.ServerResourcer

NewDiscoveryClientWithError returns a discoveryClient that reports types available to the API Server with no errors, or ErrGroupDiscoveryFailed error with the specified wantedErr

Does not report the scope of each GVK as no tests requiring a discoveryClient use scope information.

func NewErrorClient

func NewErrorClient(err error) client.Client

NewErrorClient returns a Client that always returns an error.

func NewFightHandler added in v1.15.1

func NewFightHandler() fight.Handler

NewFightHandler initiates a fake implementation of fight.Handler.

Types

type Applier added in v1.15.1

type Applier struct {
	Client      *Client
	CreateError status.Error
	UpdateError status.Error
	DeleteError status.Error
}

Applier implements a fake reconcile.Applier for use in testing.

reconcile.Applier not imported due to import cycle considerations.

func (*Applier) Create added in v1.15.1

Create implements reconcile.Applier.

func (*Applier) Delete added in v1.15.1

Delete implements reconcile.Applier.

func (*Applier) GetClient added in v1.15.1

func (a *Applier) GetClient() client.Client

GetClient implements reconcile.Applier.

func (*Applier) RemoveNomosMeta added in v1.15.1

func (a *Applier) RemoveNomosMeta(ctx context.Context, intent *unstructured.Unstructured, _ string) status.Error

RemoveNomosMeta implements reconcile.Applier.

func (*Applier) Update added in v1.15.1

func (a *Applier) Update(ctx context.Context, intendedState, _ *unstructured.Unstructured) status.Error

Update implements reconcile.Applier.

type Client

type Client struct {
	Objects map[core.ID]client.Object
	// contains filtered or unexported fields
}

Client is a fake implementation of client.Client.

func NewClient

func NewClient(t *testing.T, scheme *runtime.Scheme, objs ...client.Object) *Client

NewClient instantiates a new fake.Client pre-populated with the specified objects.

Calls t.Fatal if unable to properly instantiate Client.

func (*Client) Applier

func (c *Client) Applier() reconcile.Applier

Applier returns a fake.Applier wrapping this fake.Client. Callers using the resulting Applier will read from/write to the original fake.Client.

func (*Client) Check

func (c *Client) Check(t *testing.T, wants ...client.Object)

Check reports an error to `t` if the passed objects in wants do not match the expected set of objects in the fake.Client, and only the passed updates to Status fields were recorded.

func (*Client) Create

func (c *Client) Create(_ context.Context, obj client.Object, opts ...client.CreateOption) error

Create implements client.Client.

func (*Client) Delete

func (c *Client) Delete(_ context.Context, obj client.Object, opts ...client.DeleteOption) error

Delete implements client.Client.

func (*Client) DeleteAllOf

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

DeleteAllOf implements client.Client.

func (*Client) Get

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

Get implements client.Client.

func (*Client) List

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

List implements client.Client.

Does not paginate results.

func (*Client) Patch

func (c *Client) Patch(_ context.Context, obj client.Object, patch client.Patch, opts ...client.PatchOption) error

Patch implements client.Client.

func (*Client) RESTMapper

func (c *Client) RESTMapper() meta.RESTMapper

RESTMapper implements client.Client.

func (*Client) Scheme

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

Scheme implements client.Client.

func (*Client) Status

func (c *Client) Status() client.StatusWriter

Status implements client.Client.

func (*Client) Update

func (c *Client) Update(_ context.Context, obj client.Object, opts ...client.UpdateOption) error

Update implements client.Client. It does not update the status field.

type ConflictHandler added in v1.15.1

type ConflictHandler struct{}

ConflictHandler is a fake implementation of conflict.Handler.

func (*ConflictHandler) AddConflictError added in v1.15.1

AddConflictError is a fake implementation of AddConflictError of conflict.Handler.

func (*ConflictHandler) ConflictErrors added in v1.15.1

func (h *ConflictHandler) ConflictErrors() []status.ManagementConflictError

ConflictErrors is a fake implementation of ConflictErrors of conflict.Handler.

func (*ConflictHandler) RemoveAllConflictErrors added in v1.15.1

func (h *ConflictHandler) RemoveAllConflictErrors(schema.GroupVersionKind)

RemoveAllConflictErrors is a fake implementation of RemoveAllConflictErrors of conflict.Handler.

func (*ConflictHandler) RemoveConflictError added in v1.15.1

func (h *ConflictHandler) RemoveConflictError(queue.GVKNN)

RemoveConflictError is a fake implementation of the RemoveConflictError of conflict.Handler.

type DynamicClient added in v1.15.1

type DynamicClient struct {
	*dynamicfake.FakeDynamicClient
	// contains filtered or unexported fields
}

DynamicClient is a fake dynamic client which contains a map to store unstructured objects

func NewDynamicClient added in v1.15.1

func NewDynamicClient(t *testing.T, scheme *runtime.Scheme) *DynamicClient

NewDynamicClient instantiates a new fake.DynamicClient

func (*DynamicClient) Check added in v1.15.1

func (dc *DynamicClient) Check(t *testing.T, wants ...client.Object)

Check reports an error to `t` if the passed objects in wants do not match the expected set of objects in the fake.Client, and only the passed updates to Status fields were recorded.

func (*DynamicClient) Put added in v1.15.1

func (dc *DynamicClient) Put(t *testing.T, obj *unstructured.Unstructured)

Put adds the object to the cache, with metadata validation.

Use for test initialization to simulate exact cluster state.

func (*DynamicClient) PutAll added in v1.15.1

func (dc *DynamicClient) PutAll(t *testing.T, objs ...*unstructured.Unstructured)

PutAll loops through the objects and adds them to the cache, with metadata validation.

Use for test initialization to simulate exact cluster state.

type ErrorClient

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

ErrorClient is a Client that always returns a specified error.

func (ErrorClient) Create

Create implements client.Client.

func (ErrorClient) Delete

Delete implements client.Client.

func (ErrorClient) DeleteAllOf

DeleteAllOf implements client.Client.

func (ErrorClient) Get

Get implements client.Client.

func (ErrorClient) List

List implements client.Client.

func (ErrorClient) Patch

Patch implements client.Client.

func (ErrorClient) RESTMapper

func (e ErrorClient) RESTMapper() meta.RESTMapper

RESTMapper implements client.Client.

func (ErrorClient) Scheme

func (e ErrorClient) Scheme() *runtime.Scheme

Scheme implements client.Client.

func (ErrorClient) Status

func (e ErrorClient) Status() client.StatusWriter

Status implements client.Client.

func (ErrorClient) Update

Update implements client.Client.

type FightHandler added in v1.15.1

type FightHandler struct{}

FightHandler is a fake implementation of fight.Handler.

func (*FightHandler) AddFightError added in v1.15.1

func (h *FightHandler) AddFightError(core.ID, status.Error)

AddFightError is a fake implementation of the AddFightError of fight.Handler.

func (*FightHandler) FightErrors added in v1.15.1

func (h *FightHandler) FightErrors() []status.Error

FightErrors is a fake implementation of the FightErrors of fight.Handler.

func (*FightHandler) RemoveFightError added in v1.15.1

func (h *FightHandler) RemoveFightError(core.ID)

RemoveFightError is a fake implementation of the RemoveFightError of fight.Handler.

type UnstructuredFields added in v1.15.1

type UnstructuredFields struct {
	Object *unstructured.Unstructured
}

UnstructuredFields impliments fields.Fields to do field selection on any field in an unstructured object.

func (*UnstructuredFields) Get added in v1.15.1

func (uf *UnstructuredFields) Get(field string) (value string)

Get returns the value for the provided field.

func (*UnstructuredFields) Has added in v1.15.1

func (uf *UnstructuredFields) Has(field string) (exists bool)

Has returns whether the provided field exists.

Jump to

Keyboard shortcuts

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