...

Package kubectl

import "k8s.io/kubernetes/test/e2e/framework/kubectl"
Overview
Index

Overview ▾

Index ▾

func LogFailedContainers(ctx context.Context, c clientset.Interface, ns string, logFunc func(ftm string, args ...interface{}))
func RunKubectl(namespace string, args ...string) (string, error)
func RunKubectlInput(namespace string, data string, args ...string) (string, error)
func RunKubectlOrDie(namespace string, args ...string) string
func RunKubectlOrDieInput(namespace string, data string, args ...string) string
func RunKubectlWithFullOutput(namespace string, args ...string) (string, string, error)
func RunKubemciCmd(args ...string) (string, error)
func RunKubemciWithKubeconfig(args ...string) (string, error)
type KubectlBuilder
    func NewKubectlCommand(namespace string, args ...string) *KubectlBuilder
    func (b *KubectlBuilder) AppendEnv(env []string) *KubectlBuilder
    func (b KubectlBuilder) Exec() (string, error)
    func (b KubectlBuilder) ExecOrDie(namespace string) string
    func (b KubectlBuilder) ExecWithFullOutput() (string, string, error)
    func (b KubectlBuilder) WithStdinData(data string) *KubectlBuilder
    func (b KubectlBuilder) WithStdinReader(reader io.Reader) *KubectlBuilder
    func (b *KubectlBuilder) WithTimeout(t <-chan time.Time) *KubectlBuilder
type TestKubeconfig
    func NewTestKubeconfig(certdir, host, kubeconfig, kubecontext, kubectlpath, namespace string) *TestKubeconfig
    func (tk *TestKubeconfig) KubectlCmd(args ...string) *exec.Cmd
    func (tk *TestKubeconfig) ReadFileViaContainer(podName, containerName string, path string) (string, error)
    func (tk *TestKubeconfig) WriteFileViaContainer(podName, containerName string, path string, contents string) error

Package files

builder.go kubectl_utils.go

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

type KubectlBuilder

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

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

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

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

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
}

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