subprocess

package
v0.0.0-...-ee3d319 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2018 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Local Exec

The "local exec" implementation of the command interface is roughly equvalent to the LocalCommand interface; however, it does not enforce the use of any shell and

Index

Constants

View Source
const (
	// IMPORTANT: this user must be configured for passwordless ssh to
	// localhost on the machine where the unit tests are run, using the key
	// above
	TestRemoteUser = "mcitestuser"
	TestRemote     = "localhost"
)
View Source
const (
	MarkerTaskID   = "EVR_TASK_ID"
	MarkerAgentPID = "EVR_AGENT_PID"
)

Variables

View Source
var (
	// IMPORTANT: this key must be attached to the user below for
	// passwordless ssh to localhost on the machine where the unit tests are
	// run
	TestRemoteKey = os.ExpandEnv("${HOME}/.ssh/mcitest")
)

Functions

func KillSpawnedProcs

func KillSpawnedProcs(key string, logger grip.Journaler) error

KillSpawnedProcs cleans up any tasks that were spawned by the given task.

func TrackProcess

func TrackProcess(key string, pid int, logger grip.Journaler)

Types

type CacheLastWritten

type CacheLastWritten struct {
	LastWritten []byte
}

A trivial implementation of io.Writer that saves the last thing written. Useful for some testing situations where a line of stdout or stderr needs to be checked.

func (*CacheLastWritten) Write

func (self *CacheLastWritten) Write(p []byte) (int, error)

type Command

type Command interface {
	// Run Provides a wrapper around start and wait, that provides
	// a blocking operation, with the ability to cancel the operation
	// via the context.
	Run(context.Context) error

	Start(context.Context) error
	Wait() error

	Stop() error
	GetPid() int
	SetOutput(OutputOptions) error
}

Command provides a common interface for the three methods of managing commands in evergreen

func NewLocalCommand

func NewLocalCommand(cmdString, workingDir, shell string, env []string, scriptMode bool) Command

func NewLocalExec

func NewLocalExec(binary string, args []string, env map[string]string, workingdir string) (Command, error)

func NewRemoteCommand

func NewRemoteCommand(cmd, hostname, user string, env map[string]string, background bool, options []string, loggingDisabled bool) Command

func NewSCPCommand

func NewSCPCommand(src, dest, hostname, user string, options []string) Command

type OutputOptions

type OutputOptions struct {
	Output            io.Writer `json:"-"`
	Error             io.Writer `json:"-"`
	SuppressOutput    bool      `json:"suppress_output"`
	SuppressError     bool      `json:"suppress_error"`
	SendOutputToError bool      `json:"redirect_output_to_error"`
	SendErrorToOutput bool      `json:"redirect_error_to_output"`
}

OutputOptions provides a common way to define and represent the output behavior of a evergreen/subprocess.Command operation.

func (OutputOptions) GetError

func (o OutputOptions) GetError() io.Writer

func (OutputOptions) GetOutput

func (o OutputOptions) GetOutput() io.Writer

func (OutputOptions) Validate

func (o OutputOptions) Validate() error

Jump to

Keyboard shortcuts

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