command

package
v0.99.0-sumo-0-rc.2 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0, MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OKExitStatus specifies the command execution exit status
	// that indicates a success, A-OK.
	OKExitStatus int = 0

	// FallbackExitStatus specifies the command execution exit
	// status used when golang is unable to determine the exit
	// status.
	FallbackExitStatus int = 3
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Execution

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

func NewExecution

func NewExecution(ctx context.Context, request ExecutionRequest) *Execution

NewExecution based on an ExecutionRequest

func (*Execution) Run

func (c *Execution) Run() (resp ExecutionResponse, err error)

Run the command. May only be invoked once.

func (*Execution) Stderr

func (c *Execution) Stderr() (io.Reader, error)

func (*Execution) Stdout

func (c *Execution) Stdout() (io.Reader, error)

Stdout and Stderr return Readers for the underlying execution's output streams. Run must be called subsequently or file descriptors may be leaked.

type ExecutionRequest

type ExecutionRequest struct {
	// Command is the command to be executed. This is the only field that must
	// be set non-zero. Behaves like os/exec.Cmd's Path field.
	Command string

	// Arguments to execute the command with.
	Arguments []string

	// Env variables to include
	Env []string

	// Timeout when set non-zero functions as a timer for starting and running
	// a command on Execution.Run
	Timeout time.Duration
}

ExecutionRequest describes an external command to be executed.

type ExecutionResponse

type ExecutionResponse struct {
	// Command execution exit status.
	Status int

	// Duration provides command execution time.
	Duration time.Duration

	// Error is passed when the outcome of the execution is uncertain
	Error error
}

ExecutionResponse provides the response information of an ExecutionRequest.

Jump to

Keyboard shortcuts

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