command

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STDOUT = 0
	STDERR = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cmd

type Cmd struct {
	Command        string
	Dir            string
	Stdout         io.Writer
	Stderr         io.Writer
	CommandTimeout int
}

func (*Cmd) RetryCommand

func (c *Cmd) RetryCommand(numOfRetries int) error

RetryCommand retries the given command, with exponential backoff, maxing at 5 min, for numOfRetries times. Returns error if all retries fail, nil otherwise.

func (*Cmd) RetryCommandWithOutput

func (c *Cmd) RetryCommandWithOutput(numOfRetries int) ([]byte, error)

RetryCommandWithOutput retries the given command, with exponential backoff, maxing at 5 min, for numOfRetries times. returns (nil, error) if all retries fail, (output, nil) otherwise.

type Wrapper

type Wrapper struct {
	// contains filtered or unexported fields
}

Wrapper struct holds data for the wrapper around stdout & stderr.

func GetStdErr

func GetStdErr(prefix string) Wrapper

GetStdErr returns an io.Writer for exec with the defined prefix. Cannot be used with cmd.CombinedOutput().

func GetStdOut

func GetStdOut(prefix string) Wrapper

GetStdOut returns an io.Writer for exec with the defined prefix. Cannot be used with cmd.CombinedOutput().

func (Wrapper) Write

func (w Wrapper) Write(p []byte) (n int, err error)

Write is implementation of the function from io.Writer interface.

Jump to

Keyboard shortcuts

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