exec

package
v0.0.0-...-b25b198 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package exec implements command execution functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KubectlApplyWithArgs

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

KubectlApplyWithArgs applies config with args

func KubectlWithArgs

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

KubectlWithArgs runs kubectl command with args

Types

type Command

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

Command wraps exec.Command

func NewCommand

func NewCommand(opts ...Option) *Command

NewCommand returns a 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.

func (*Command) RunAndRedirectOutput

func (c *Command) RunAndRedirectOutput(ctx context.Context) error

RunAndRedirectOutput executes command and redirects output

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

func WithCommand

func WithCommand(command string) Option

WithCommand defines the command

func WithEnv

func WithEnv(args ...string) Option

WithEnv sets env variables

func WithStdin

func WithStdin(stdin io.Reader) Option

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

func WithStdout

func WithStdout(stdout io.Writer) Option

WithStdout sets up the command to write to io.Writer.

Jump to

Keyboard shortcuts

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