kubectl

package
v1.28.0-alpha.3...-059ce4e Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogFailedContainers

func LogFailedContainers(ctx context.Context, c clientset.Interface, ns string, logFunc func(ftm string, args ...interface{}))

LogFailedContainers runs `kubectl logs` on a failed containers.

func RunKubectl

func RunKubectl(namespace string, args ...string) (string, error)

RunKubectl is a convenience wrapper over kubectlBuilder

func RunKubectlInput

func RunKubectlInput(namespace string, data string, args ...string) (string, error)

RunKubectlInput is a convenience wrapper over kubectlBuilder that takes input to stdin

func RunKubectlOrDie

func RunKubectlOrDie(namespace string, args ...string) string

RunKubectlOrDie is a convenience wrapper over kubectlBuilder

func RunKubectlOrDieInput

func RunKubectlOrDieInput(namespace string, data string, args ...string) string

RunKubectlOrDieInput is a convenience wrapper over kubectlBuilder that takes input to stdin

func RunKubectlWithFullOutput

func RunKubectlWithFullOutput(namespace string, args ...string) (string, string, error)

RunKubectlWithFullOutput is a convenience wrapper over kubectlBuilder It will also return the command's stderr.

func RunKubemciCmd

func RunKubemciCmd(args ...string) (string, error)

RunKubemciCmd is a convenience wrapper over kubectlBuilder to run kubemci. It assumes that kubemci exists in PATH.

func RunKubemciWithKubeconfig

func RunKubemciWithKubeconfig(args ...string) (string, error)

RunKubemciWithKubeconfig is a convenience wrapper over RunKubemciCmd

Types

type KubectlBuilder

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

KubectlBuilder is used to build, customize and execute a kubectl Command. Add more functions to customize the builder as needed.

func NewKubectlCommand

func NewKubectlCommand(namespace string, args ...string) *KubectlBuilder

NewKubectlCommand returns a KubectlBuilder for running kubectl.

func (*KubectlBuilder) AppendEnv

func (b *KubectlBuilder) AppendEnv(env []string) *KubectlBuilder

AppendEnv appends the given environment and returns itself.

func (KubectlBuilder) Exec

func (b KubectlBuilder) Exec() (string, error)

Exec runs the kubectl executable.

func (KubectlBuilder) ExecOrDie

func (b KubectlBuilder) ExecOrDie(namespace string) string

ExecOrDie runs the kubectl executable or dies if error occurs.

func (KubectlBuilder) ExecWithFullOutput

func (b KubectlBuilder) ExecWithFullOutput() (string, string, error)

ExecWithFullOutput runs the kubectl executable, and returns the stdout and stderr.

func (KubectlBuilder) WithStdinData

func (b KubectlBuilder) WithStdinData(data string) *KubectlBuilder

WithStdinData sets the given data to stdin and returns itself.

func (KubectlBuilder) WithStdinReader

func (b KubectlBuilder) WithStdinReader(reader io.Reader) *KubectlBuilder

WithStdinReader sets the given reader and returns itself.

func (*KubectlBuilder) WithTimeout

func (b *KubectlBuilder) WithTimeout(t <-chan time.Time) *KubectlBuilder

WithTimeout sets the given timeout and returns itself.

type TestKubeconfig

type TestKubeconfig struct {
	CertDir     string
	Host        string
	KubeConfig  string
	KubeContext string
	KubectlPath string
	Namespace   string // Every test has at least one namespace unless creation is skipped
}

TestKubeconfig is a struct containing the needed attributes from TestContext and Framework(Namespace).

func NewTestKubeconfig

func NewTestKubeconfig(certdir, host, kubeconfig, kubecontext, kubectlpath, namespace string) *TestKubeconfig

NewTestKubeconfig returns a new Kubeconfig struct instance.

func (*TestKubeconfig) KubectlCmd

func (tk *TestKubeconfig) KubectlCmd(args ...string) *exec.Cmd

KubectlCmd runs the kubectl executable through the wrapper script.

func (*TestKubeconfig) ReadFileViaContainer

func (tk *TestKubeconfig) ReadFileViaContainer(podName, containerName string, path string) (string, error)

ReadFileViaContainer reads a file using kubectl exec cat <path>.

func (*TestKubeconfig) WriteFileViaContainer

func (tk *TestKubeconfig) WriteFileViaContainer(podName, containerName string, path string, contents string) error

WriteFileViaContainer writes a file using kubectl exec echo <contents> > <path> via specified container because of the primitive technique we're using here, we only allow ASCII alphanumeric characters

Jump to

Keyboard shortcuts

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