fake

package
v3.15.4 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2024 License: Apache-2.0 Imports: 8 Imported by: 34

Documentation

Overview

Package fake implements various fake KubeClients for use in testing

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FailingKubeClient

type FailingKubeClient struct {
	PrintingKubeClient
	CreateError                      error
	GetError                         error
	WaitError                        error
	DeleteError                      error
	DeleteWithPropagationError       error
	WatchUntilReadyError             error
	UpdateError                      error
	BuildError                       error
	BuildTableError                  error
	BuildDummy                       bool
	BuildUnstructuredError           error
	WaitAndGetCompletedPodPhaseError error
	WaitDuration                     time.Duration
}

FailingKubeClient implements KubeClient for testing purposes. It also has additional errors you can set to fail different functions, otherwise it delegates all its calls to `PrintingKubeClient`

func (*FailingKubeClient) Build

Build returns the configured error if set or prints

func (*FailingKubeClient) BuildTable added in v3.11.0

func (f *FailingKubeClient) BuildTable(r io.Reader, _ bool) (kube.ResourceList, error)

BuildTable returns the configured error if set or prints

func (*FailingKubeClient) Create

func (f *FailingKubeClient) Create(resources kube.ResourceList) (*kube.Result, error)

Create returns the configured error if set or prints

func (*FailingKubeClient) Delete

func (f *FailingKubeClient) Delete(resources kube.ResourceList) (*kube.Result, []error)

Delete returns the configured error if set or prints

func (*FailingKubeClient) DeleteWithPropagationPolicy added in v3.12.0

func (f *FailingKubeClient) DeleteWithPropagationPolicy(resources kube.ResourceList, policy metav1.DeletionPropagation) (*kube.Result, []error)

DeleteWithPropagationPolicy returns the configured error if set or prints

func (*FailingKubeClient) Get added in v3.11.0

func (f *FailingKubeClient) Get(resources kube.ResourceList, related bool) (map[string][]runtime.Object, error)

Get returns the configured error if set or prints

func (*FailingKubeClient) Update

func (f *FailingKubeClient) Update(r, modified kube.ResourceList, ignoreMe bool) (*kube.Result, error)

Update returns the configured error if set or prints

func (*FailingKubeClient) Wait

func (f *FailingKubeClient) Wait(resources kube.ResourceList, d time.Duration) error

Waits the amount of time defined on f.WaitDuration, then returns the configured error if set or prints.

func (*FailingKubeClient) WaitAndGetCompletedPodPhase

func (f *FailingKubeClient) WaitAndGetCompletedPodPhase(s string, d time.Duration) (v1.PodPhase, error)

WaitAndGetCompletedPodPhase returns the configured error if set or prints

func (*FailingKubeClient) WaitForDelete added in v3.7.0

func (f *FailingKubeClient) WaitForDelete(resources kube.ResourceList, d time.Duration) error

WaitForDelete returns the configured error if set or prints

func (*FailingKubeClient) WaitWithJobs added in v3.5.0

func (f *FailingKubeClient) WaitWithJobs(resources kube.ResourceList, d time.Duration) error

WaitWithJobs returns the configured error if set or prints

func (*FailingKubeClient) WatchUntilReady

func (f *FailingKubeClient) WatchUntilReady(resources kube.ResourceList, d time.Duration) error

WatchUntilReady returns the configured error if set or prints

type PrintingKubeClient

type PrintingKubeClient struct {
	Out io.Writer
}

PrintingKubeClient implements KubeClient, but simply prints the reader to the given output.

func (*PrintingKubeClient) Build

Build implements KubeClient Build.

func (*PrintingKubeClient) BuildTable added in v3.11.0

func (p *PrintingKubeClient) BuildTable(_ io.Reader, _ bool) (kube.ResourceList, error)

BuildTable implements KubeClient BuildTable.

func (*PrintingKubeClient) Create

func (p *PrintingKubeClient) Create(resources kube.ResourceList) (*kube.Result, error)

Create prints the values of what would be created with a real KubeClient.

func (*PrintingKubeClient) Delete

func (p *PrintingKubeClient) Delete(resources kube.ResourceList) (*kube.Result, []error)

Delete implements KubeClient delete.

It only prints out the content to be deleted.

func (*PrintingKubeClient) DeleteWithPropagationPolicy added in v3.12.0

func (p *PrintingKubeClient) DeleteWithPropagationPolicy(resources kube.ResourceList, _ metav1.DeletionPropagation) (*kube.Result, []error)

DeleteWithPropagationPolicy implements KubeClient delete.

It only prints out the content to be deleted.

func (*PrintingKubeClient) Get added in v3.11.0

func (p *PrintingKubeClient) Get(resources kube.ResourceList, _ bool) (map[string][]runtime.Object, error)

func (*PrintingKubeClient) IsReachable

func (p *PrintingKubeClient) IsReachable() error

IsReachable checks if the cluster is reachable

func (*PrintingKubeClient) Update

func (p *PrintingKubeClient) Update(_, modified kube.ResourceList, _ bool) (*kube.Result, error)

Update implements KubeClient Update.

func (*PrintingKubeClient) Wait

func (p *PrintingKubeClient) Wait(resources kube.ResourceList, _ time.Duration) error

func (*PrintingKubeClient) WaitAndGetCompletedPodPhase

func (p *PrintingKubeClient) WaitAndGetCompletedPodPhase(_ string, _ time.Duration) (v1.PodPhase, error)

WaitAndGetCompletedPodPhase implements KubeClient WaitAndGetCompletedPodPhase.

func (*PrintingKubeClient) WaitForDelete added in v3.7.0

func (p *PrintingKubeClient) WaitForDelete(resources kube.ResourceList, _ time.Duration) error

func (*PrintingKubeClient) WaitWithJobs added in v3.5.0

func (p *PrintingKubeClient) WaitWithJobs(resources kube.ResourceList, _ time.Duration) error

func (*PrintingKubeClient) WatchUntilReady

func (p *PrintingKubeClient) WatchUntilReady(resources kube.ResourceList, _ time.Duration) error

WatchUntilReady implements KubeClient WatchUntilReady.

Jump to

Keyboard shortcuts

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