Back to

Package exec

Latest Go to latest

The latest major version is .

Published: May 15, 2020 | License: Apache-2.0 | Module:


func KubectlApply

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

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

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.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier