kubectl

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FakePodState

type FakePodState int
const (
	FakePodUnknown FakePodState = iota
	FakePodRunning
	FakePodCompleted
	FakePodError
)

func (FakePodState) String

func (i FakePodState) String() string

type Kubectl

type Kubectl struct {
	Log logr.Logger
}

Kubectl is able to perform kubectl cli commands.

func (Kubectl) Namespaces added in v0.1.6

func (k Kubectl) Namespaces(kubeconfigPath, labelSelector string) ([]v1.Namespace, error)

Namespaces returns all the Namespaces matching labelSelector in the cluster addressed by kubeconfigPath.

func (Kubectl) PodDelete

func (k Kubectl) PodDelete(kubeconfigPath, namespace, name string) error

PodDelete deletes a Pod.

func (Kubectl) PodLog

func (k Kubectl) PodLog(kubeconfigPath, namespace, name string) (string, error)

PodLog returns the log of a Pod.

func (Kubectl) PodRun

func (k Kubectl) PodRun(kubeconfigPath, namespace, name, image, cmd string) error

PodRun runs a Pod.

func (Kubectl) PodState

func (k Kubectl) PodState(kubeconfigPath, namespace, name string) (string, error)

PodState returns the "Ready" status reason of the Pod in the cluster addressed by kubeconfigPath. State is PodRunning, PodCompleted, ContainersNotReady or empty when no Pod is found.

func (Kubectl) StorageClasses

func (k Kubectl) StorageClasses(kubeconfigPath string) ([]storagev1.StorageClass, error)

StorageClasses returns all the StorageClasses in the cluster addressed by kubeconfigPath.

func (Kubectl) WipeCluster added in v0.1.5

func (k Kubectl) WipeCluster(kubeconfigPath string) error

WipeCluster removes resources so all cluster nodes can be drained without errors. Arg kubeconfigRaw contains the kubeconfig file contents.

type KubectlFake

type KubectlFake struct {
	PodRunTally, PodDeleteTally, WipeClusterTally int
	// contains filtered or unexported fields
}

KubectlFake provides a Kubectler for testing.

func (*KubectlFake) PodDelete

func (k *KubectlFake) PodDelete(kubeconfigPath, namespace, name string) error

func (*KubectlFake) PodLog

func (k *KubectlFake) PodLog(kubeconfigPath, namespace, name string) (string, error)

func (*KubectlFake) PodRun

func (k *KubectlFake) PodRun(kubeconfigPath, namespace, name, image, cmd string) error

func (*KubectlFake) PodState

func (k *KubectlFake) PodState(kubeconfigPath, namespace, name string) (string, error)

func (KubectlFake) StorageClasses

func (k KubectlFake) StorageClasses(kubeconfigPath string) ([]storagev1.StorageClass, error)

StorageClasses returns all the StorageClasses in the cluster addressed by kubeconfigPath.

func (*KubectlFake) WipeCluster added in v0.1.5

func (k *KubectlFake) WipeCluster(kubeconfigPath string) error

WipeCluster removes resources before cluster delete.

type Kubectrler

type Kubectrler interface {
	// PodState returns the state of a Pod in the cluster addressed by kubeconfigPath.
	// State is FakePodRunning, FakePodCompleted, FakePodError or empty when no Pod is found.
	PodState(kubeconfigPath, namespace, name string) (string, error)
	// PodRun run a Pod
	PodRun(kubeconfigPath, namespace, name, image, cmd string) error
	// PodLog returns the log of a Pod.
	PodLog(kubeconfigPath, namespace, name string) (string, error)
	// PodDelete deletes a Pod.
	PodDelete(kubeconfigPath, namespace, name string) error
	// StorageClasses returns all the StorageClasses in the cluster addressed by kubeconfigPath.
	StorageClasses(kubeconfigPath string) ([]storagev1.StorageClass, error)
	// WipeCluster removes resources so all cluster nodes can be drained without errors.
	WipeCluster(kubeconfigPath string) error
}

Kubectrler is able to perform kubectl cli commands.

Jump to

Keyboard shortcuts

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