exec

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: Apache-2.0 Imports: 4 Imported by: 9

Documentation

Overview

Package exec implements command execution functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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