exec

package
v1.1.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: Apache-2.0 Imports: 6 Imported by: 8

Documentation

Overview

Package exec implements command execution functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KubectlApply

func KubectlApply(ctx context.Context, kubeconfigPath string, resources []byte, args ...string) error

KubectlApply shells out to kubectl apply.

TODO: Remove this usage of kubectl and replace with a function from apply.go using the controller-runtime client.

func KubectlWait

func KubectlWait(ctx context.Context, kubeconfigPath string, args ...string) error

KubectlWait shells out to kubectl wait.

Types

type Command

type Command struct {
	Cmd   string
	Args  []string
	Stdin io.Reader
}

Command wraps exec.Command with specific functionality. This differentiates itself from the standard library by always collecting stdout and stderr. Command improves the UX of exec.Command for our specific use case.

func NewCommand

func NewCommand(opts ...Option) *Command

NewCommand returns a configured Command.

func (*Command) Run

func (c *Command) Run(ctx context.Context) ([]byte, []byte, error)

Run executes the command and returns stdout, stderr and the error if there is any.

type Option

type Option func(*Command)

Option is a functional option type that modifies a Command.

func WithArgs

func WithArgs(args ...string) Option

WithArgs sets the arguments for the command such as `get pods -n kube-system` to the command `kubectl`.

func WithCommand

func WithCommand(command string) Option

WithCommand defines the command to run such as `kubectl` or `kind`.

func WithStdin

func WithStdin(stdin io.Reader) Option

WithStdin sets up the command to read from this io.Reader.

Jump to

Keyboard shortcuts

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