testshell

package
v1.17.3 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 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 TestShell

type TestShell struct {
	// Context to use, if not specified by the method.
	Context context.Context
	// KubeConfigPath is the path to the kubeconfig file for the cluster,
	// used for kubectl commands.
	KubeConfigPath string
	// Logger for methods to use.
	Logger *testlogger.TestLogger
}

TestShell is a helper utility to execute shell commands in a test. Handles logging and injection of the KUBECONFIG as argument or env var.

func (*TestShell) Command

func (tc *TestShell) Command(name string, args ...string) *exec.Cmd

Command is a convenience method for invoking a subprocess with the KUBECONFIG environment variable set. Setting the environment variable directly in the test process is not thread safe.

func (*TestShell) Docker

func (tc *TestShell) Docker(args ...string) ([]byte, error)

Docker is a convenience method for calling docker. Returns STDOUT & STDERR combined, and an error if docker exited abnormally.

func (*TestShell) ExecWithDebug added in v1.17.0

func (tc *TestShell) ExecWithDebug(name string, args ...string) ([]byte, error)

ExecWithDebug is a convenience method for invoking a subprocess with the KUBECONFIG environment variable and debug logging.

func (*TestShell) Git

func (tc *TestShell) Git(args ...string) ([]byte, error)

Git is a convenience method for calling git. Returns STDOUT & STDERR combined, and an error if git exited abnormally.

func (*TestShell) Helm added in v1.16.0

func (tc *TestShell) Helm(args ...string) ([]byte, error)

Helm is a convenience method for calling helm. Returns STDOUT & STDERR combined, and an error if helm exited abnormally.

func (*TestShell) Kubectl

func (tc *TestShell) Kubectl(args ...string) ([]byte, error)

Kubectl is a convenience method for calling kubectl against the currently-connected cluster. Returns STDOUT, and an error if kubectl exited abnormally.

If you want to fail the test immediately on failure, use MustKubectl.

func (*TestShell) KubectlContext

func (tc *TestShell) KubectlContext(ctx context.Context, args ...string) ([]byte, error)

KubectlContext is similar to TestShell.Kubectl but allows using a context to cancel (kill signal) the kubectl command.

Jump to

Keyboard shortcuts

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