Help us shape the future of Go! Take the 2026 Go Developer Survey

util

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2021 License: Apache-2.0, Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRemoteCmdFailed = errors.New("remote command failed")
)

Functions

func CopyToPod

func CopyToPod(
	ctx context.Context,
	podName, namespace string,
	buffer *bytes.Buffer, destPath string,
) error

func ErrFromStderr

func ErrFromStderr(stderr bytes.Buffer) error

ErrFromStderr parses stderr to find last error message, which would be returned as error or <nil> otherwise.

func ExecCommandInContainer

func ExecCommandInContainer(
	ctx context.Context,
	pod, container, namespace string,
	cmd ...string,
) (io.Reader, io.Reader, error)

ExecCommandInContainer executes a command in the given `container` of `pod` and return stdout, stderr as error.

func ExecCommandInPod

func ExecCommandInPod(ctx context.Context, podName, namespace string, cmd ...string) (io.Reader, io.Reader, error)

ExecCommandInPod executes a command in the default container of the given `pod` and return stdout, stderr and error.

func ExecShellInContainer

func ExecShellInContainer(
	ctx context.Context,
	podName, containerName, namespace string,
	cmd string,
) (io.Reader, io.Reader, error)

ExecShellInContainer executes a `sh` shell command in the given `container` of `pod` and return stdout, stderr and error.

func ExecShellInPod

func ExecShellInPod(ctx context.Context, podName, namespace string, cmd string) (io.Reader, io.Reader, error)

ExecShellInPod executes a `sh` shell command in the default container of the given `pod` and return stdout, stderr and error.

func FormShellCommand

func FormShellCommand(cmd ...string) string

FormShellCommand forms command for shell execution `sh -c "cmd"`.

func GetLastLine

func GetLastLine(reader io.Reader) string

func PromptStderrView

func PromptStderrView(stderr io.Reader) bool

PromptStderrView asks whether the full log output from stderr should be viewed.

func ValuesFromFile

func ValuesFromFile(path string) (map[string]interface{}, error)

ValuesFromFile retrieves value from file on given `path` structured as map.

func WaitForEvent

func WaitForEvent(
	ctx context.Context, cancel context.CancelFunc,
	watcher watch.Interface,
	onEvent func(watch.Event) bool,
	msgStart, msgSuccess, msgWarning, msgTimeout func() string,
) (bool, error)

WaitForEvent waits for custom event occurrence.

func WaitForJobComplete

func WaitForJobComplete(
	ctx context.Context,
	name *string,
	selector string, namespace string,
) (bool, error)

WaitForJobComplete waits for job with given 'selector' and 'name' in given 'namespace' to complete.

func WaitForPodReady

func WaitForPodReady(
	ctx context.Context,
	name *string,
	selector string, namespace string,
) (bool, error)

WaitForPodReady waits for pod with given 'selector' and 'name' in given 'namespace' to become ready.

func WrapWithStderrViewPrompt

func WrapWithStderrViewPrompt(err error, stderr io.Reader, printErrPriorPrompt bool) error

WrapWithStderrViewPrompt wraps `err` from remote container with `msg`, and asks whether the full log output from stderr should be viewed.

func WriteBytesToTar

func WriteBytesToTar(targetPath string, reader SizedReader, writer io.Writer) error

WriteBytesToTar puts bytes from `reader` into the `targetPath` file in tar archive.

func WriteBytesToTarGzip

func WriteBytesToTarGzip(targetPath string, reader SizedReader, writer io.Writer) error

WriteBytesToTarGzip puts bytes from `reader` into the `targetPath` file in tar.gz archive, by performing pipeline write to WriteBytesToTar.

Types

type SecretInterface

type SecretInterface struct {
	v1.SecretInterface
}

SecretInterface provides additional methods for dealing with Kubernetes secrets.

func SecretAdapter

func SecretAdapter(i v1.SecretInterface) *SecretInterface

SecretAdapter constructs new SecretInterface adapter instance.

func (*SecretInterface) CreateOrUpdate

func (i *SecretInterface) CreateOrUpdate(ctx context.Context, secret corev1.Secret) (*corev1.Secret, error)

CreateOrUpdate takes the representation of a secret and either creates it or update existing one.

type SizedReader

type SizedReader interface {
	io.Reader
	Len() int
}

Jump to

Keyboard shortcuts

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