command

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2019 License: Apache-2.0 Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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