command

package
v1.6.3-v1.27.5-k3s1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteCommand

func ExecuteCommand(commands []string) ([]string, error)

func SetPassword

func SetPassword(password string) error

Types

type LocalShell

type LocalShell struct{}

LocalShell is the default shell that executes commands locally, basically calling `sh -c <cmd>` at the end of the day.

func (LocalShell) Execute

func (LocalShell) Execute(ctx context.Context, cmd string) ([]byte, error)

type Shell

type Shell interface {
	// Execute runs the given command and returns the output and error.
	Execute(ctx context.Context, cmd string) (output []byte, err error)
}

Wrap the exec call in a struct so that we can mock it in our tests.

var DefaultShell Shell = LocalShell{}

DefaultShell will be overridden in tests Set the default shell to be the local shell. TODO: still not happy with this pattern

Jump to

Keyboard shortcuts

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