k8s

package
v0.0.0-...-452dcce Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Get(into sdk.Object, opts ...sdk.GetOption) error
	List(namespace string, into sdk.Object, opts ...sdk.ListOption) error
	Create(object sdk.Object) error
	Update(object sdk.Object) error
	Run(pod *corev1.Pod, containerIdx int, command []string) (string, string, error)
	Patch(object sdk.Object, pt types.PatchType, patch []byte) (err error)
}

Client is currently an interface because this code should be totally replaced once the refactors of the operator-sdk is complete

type Finalizer

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

Finalizer manages the finalizers for resources in kubernetes

func NewFinalizer

func NewFinalizer(driver Client, finalizerValue string) *Finalizer

NewFinalizer constructs a new finalizer manager

func (*Finalizer) Add

func (c *Finalizer) Add(resource finalizable) error

Add adds a finalizer to an object

func (*Finalizer) IsDeletionCandidate

func (c *Finalizer) IsDeletionCandidate(resource finalizable) bool

IsDeletionCandidate checks if the resource is a candidate for deletion

func (*Finalizer) NeedToAdd

func (c *Finalizer) NeedToAdd(resource finalizable) bool

NeedToAdd checks if the resource should have but does not have the finalizer

func (*Finalizer) Remove

func (c *Finalizer) Remove(resource finalizable) error

Remove removes a finalizer from an object

type MockClient

type MockClient struct {
	RunStdOut string
	RunStdErr string
	RunErr    error

	PatchCallback  func(object sdk.Object, pt types.PatchType, patch []byte) error
	GetCallback    func(into sdk.Object, opts ...sdk.GetOption) error
	CreateCallback func(object sdk.Object) error
	UpdateCallback func(object sdk.Object) error
	ListCallback   func(namespace string, into sdk.Object, opts ...sdk.ListOption) error
	RunCallback    func(pod *corev1.Pod, containerIdx int, command []string) (string, string, error)
}

MockClient implements a Mock of the sdk client

func (*MockClient) Create

func (c *MockClient) Create(object sdk.Object) error

Create returns mock value

func (*MockClient) Get

func (c *MockClient) Get(into sdk.Object, opts ...sdk.GetOption) error

Get returns mock value

func (*MockClient) List

func (c *MockClient) List(namespace string, into sdk.Object, opts ...sdk.ListOption) error

List returns mock values

func (*MockClient) Patch

func (c *MockClient) Patch(object sdk.Object, pt types.PatchType, patch []byte) error

Patch returns mock value

func (*MockClient) Run

func (c *MockClient) Run(pod *corev1.Pod, containerIdx int, command []string) (string, string, error)

Run returns mock values

func (*MockClient) Update

func (c *MockClient) Update(object sdk.Object) error

Update returns mock value

type OperatorSdkClient

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

OperatorSdkClient is a class that allows for the operator-sdk to be injected for unit testing purposes

func NewOperatorSdkClient

func NewOperatorSdkClient() *OperatorSdkClient

NewOperatorSdkClient returns a new client for interacting with the operator-sdk/kubernetes

func (*OperatorSdkClient) Create

func (c *OperatorSdkClient) Create(object sdk.Object) error

Create resource in kube

func (*OperatorSdkClient) Get

func (c *OperatorSdkClient) Get(into sdk.Object, opts ...sdk.GetOption) error

Get resource in kube

func (*OperatorSdkClient) List

func (c *OperatorSdkClient) List(namespace string, into sdk.Object, opts ...sdk.ListOption) error

List resources from kube

func (*OperatorSdkClient) Patch

func (c *OperatorSdkClient) Patch(object sdk.Object, pt types.PatchType, patch []byte) error

Patch resource in kube

func (*OperatorSdkClient) Run

func (c *OperatorSdkClient) Run(pod *corev1.Pod, containerIdx int, command []string) (string, string, error)

Run executes a command inside a container inside a pod

func (*OperatorSdkClient) Update

func (c *OperatorSdkClient) Update(object sdk.Object) error

Update resource in kube

Jump to

Keyboard shortcuts

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