kubectl

package
v1.27.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: Apache-2.0 Imports: 20 Imported by: 39

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 added in v1.26.0

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

RunKubectl is a convenience wrapper over kubectlBuilder

func RunKubectlInput added in v1.26.0

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

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

func RunKubectlOrDie added in v1.26.0

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

RunKubectlOrDie is a convenience wrapper over kubectlBuilder

func RunKubectlOrDieInput added in v1.26.0

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

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

func RunKubectlWithFullOutput added in v1.26.0

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 added in v1.26.0

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 added in v1.26.0

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

RunKubemciWithKubeconfig is a convenience wrapper over RunKubemciCmd

Types

type KubectlBuilder added in v1.26.0

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 added in v1.26.0

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

NewKubectlCommand returns a KubectlBuilder for running kubectl.

func (KubectlBuilder) Exec added in v1.26.0

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

Exec runs the kubectl executable.

func (KubectlBuilder) ExecOrDie added in v1.26.0

func (b KubectlBuilder) ExecOrDie(namespace string) string

ExecOrDie runs the kubectl executable or dies if error occurs.

func (KubectlBuilder) ExecWithFullOutput added in v1.26.0

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

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

func (*KubectlBuilder) WithEnv added in v1.26.0

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

WithEnv sets the given environment and returns itself.

func (KubectlBuilder) WithStdinData added in v1.26.0

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

WithStdinData sets the given data to stdin and returns itself.

func (KubectlBuilder) WithStdinReader added in v1.26.0

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

WithStdinReader sets the given reader and returns itself.

func (*KubectlBuilder) WithTimeout added in v1.26.0

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