Documentation ¶
Index ¶
- type CommandExecutor
- func (e *CommandExecutor) CombinedOutputCommandAsHost(ctx context.Context, command string, arg ...string) ([]byte, error)
- func (e *CommandExecutor) RunCommandAsHost(ctx context.Context, command string, arg ...string) error
- func (e *CommandExecutor) RunCommandAsHostInto(ctx context.Context, into any, command string, arg ...string) error
- func (e *CommandExecutor) StartCommandWithOutputAsHost(ctx context.Context, command string, arg ...string) (io.ReadCloser, error)
- func (*CommandExecutor) WrapCommandWithNSenter(command string, arg ...string) (string, []string)
- type Error
- type Executor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommandExecutor ¶
type CommandExecutor struct{}
CommandExecutor is an Executor type
func (*CommandExecutor) CombinedOutputCommandAsHost ¶
func (e *CommandExecutor) CombinedOutputCommandAsHost(ctx context.Context, command string, arg ...string) ([]byte, error)
CombinedOutputCommandAsHost executes a command as host and returns an error if the command fails. it finishes the run and the output will be printed to the log.
func (*CommandExecutor) RunCommandAsHost ¶
func (e *CommandExecutor) RunCommandAsHost(ctx context.Context, command string, arg ...string) error
RunCommandAsHost executes a command as host and returns an error if the command fails. it finishes the run and the output will be printed to the log.
func (*CommandExecutor) RunCommandAsHostInto ¶
func (e *CommandExecutor) RunCommandAsHostInto(ctx context.Context, into any, command string, arg ...string) error
RunCommandAsHostInto executes a command as host and returns an error if the command fails. it finishes the run and decodes the output via JSON into the provided struct pointer. if the struct pointer is nil, the output will be printed to the log instead.
func (*CommandExecutor) StartCommandWithOutputAsHost ¶
func (e *CommandExecutor) StartCommandWithOutputAsHost(ctx context.Context, command string, arg ...string) (io.ReadCloser, error)
StartCommandWithOutputAsHost executes a command with output as host and returns the output as a ReadCloser. The caller is responsible for closing the ReadCloser. Not calling close on this method will result in a resource leak.
func (*CommandExecutor) WrapCommandWithNSenter ¶
func (*CommandExecutor) WrapCommandWithNSenter(command string, arg ...string) (string, []string)
WrapCommandWithNSenter wraps the command and arguments with nsenter arguments.
type Error ¶
Error is an error that wraps the original error and the stderr output of the command if found. It also provides an exit code if present that can be used to determine the type of error.
func AsExecError ¶
AsExecError returns the Error from the error if it exists and a bool indicating if is an Error or not.
type Executor ¶
type Executor interface { StartCommandWithOutputAsHost(ctx context.Context, command string, arg ...string) (io.ReadCloser, error) RunCommandAsHost(ctx context.Context, command string, arg ...string) error CombinedOutputCommandAsHost(ctx context.Context, command string, arg ...string) ([]byte, error) RunCommandAsHostInto(ctx context.Context, into any, command string, arg ...string) error WrapCommandWithNSenter(command string, arg ...string) (string, []string) }
Executor is the interface for running exec commands