command

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: May 27, 2019 License: Apache-2.0 Imports: 5 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExecResult

type ExecResult struct {
	StdOut   string
	StdErr   string
	ExitCode int
	Duration time.Duration
	Err      error
}

ExecResult returns the outcome of linux command execution

type Executor

type Executor interface {
	// RunCommand runs a command once and returns ExecResult
	RunCommand(command string, args ...string) *ExecResult

	// RunCommandWithRetries runs a command until the ExecResult.ExitCode is in okExitCodes or
	// the maximum number of retries is reached. Commands are executed one after another without
	// any delay.
	RunCommandWithRetries(retries int, okExitCodes []int, command string, args ...string) *ExecResult

	// RunCommandWithRetriesAndDelay runs a command until the ExecResult.ExitCode is in okExitCodes or
	// the maximum number of retries is reached. Commands are executed one after another with a delay
	// of retryWaitMilliseconds between each execution.
	RunCommandWithRetriesAndDelay(retries int, retryWaitMilliseconds int, okExitCodes []int,
		command string, args ...string) *ExecResult
}

Executor allows you to run operating system commands from go

func NewExecutor

func NewExecutor() Executor

NewExecutor returns a new Linux command executor.

type LinuxExecutor

type LinuxExecutor struct {
}

LinuxExecutor implements Executor for Linux

func (*LinuxExecutor) RunCommand

func (l *LinuxExecutor) RunCommand(command string, args ...string) *ExecResult

RunCommand runs a command once and returns ExecResult

func (*LinuxExecutor) RunCommandWithRetries

func (l *LinuxExecutor) RunCommandWithRetries(retries int, okExitCodes []int, command string,
	args ...string) *ExecResult

RunCommandWithRetries runs a command until the ExecResult.ExitCode is in okExitCodes or the maximum number of retries is reached. Commands are executed one after another without any delay.

func (*LinuxExecutor) RunCommandWithRetriesAndDelay

func (l *LinuxExecutor) RunCommandWithRetriesAndDelay(retries int, retryWaitMilliseconds int,
	okExitCodes []int, command string, args ...string) *ExecResult

RunCommandWithRetriesAndDelay runs a command until the ExecResult.ExitCode is in okExitCodes or the maximum number of retries is reached. Commands are executed one after another with a delay of retryWaitMilliseconds between each execution.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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