command

package
v0.0.0-...-a204096 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2016 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

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"
)

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

This section is empty.

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 Expansions

type Expansions map[string]string

Wrapper for an expansions map, with some utility functions.

func NewExpansions

func NewExpansions(initMap map[string]string) *Expansions

Return a new Expansions object with all of the specified expansions present.

func (*Expansions) Exists

func (self *Expansions) Exists(expansion string) bool

Check if a value is present in the expansions.

func (*Expansions) ExpandString

func (self *Expansions) ExpandString(toExpand string) (string, error)

Apply the expansions to a single string. Return the expanded string, or an error if the input string is malformed.

func (*Expansions) Get

func (self *Expansions) Get(expansion string) string

Get a single value from the expansions. Return the value, or the empty string if the value is not present.

func (*Expansions) Put

func (self *Expansions) Put(expansion string, value string)

Set a single value in the expansions.

func (*Expansions) Update

func (self *Expansions) Update(newItems map[string]string)

Update all of the specified keys in the expansions to point to the specified values.

func (*Expansions) UpdateFromYaml

func (self *Expansions) UpdateFromYaml(filename string) error

Read a map of keys/values from the given file, and update the expansions to include them (overwriting any duplicates with the new value).

type LocalCommand

type LocalCommand struct {
	CmdString        string
	WorkingDirectory string
	Shell            string
	Environment      []string
	ScriptMode       bool
	Stdout           io.Writer
	Stderr           io.Writer
	Cmd              *exec.Cmd
}

func (*LocalCommand) PrepToRun

func (lc *LocalCommand) PrepToRun(expansions *Expansions) error

func (*LocalCommand) Run

func (lc *LocalCommand) Run() error

func (*LocalCommand) Start

func (lc *LocalCommand) Start() error

func (*LocalCommand) Stop

func (lc *LocalCommand) Stop() error

type LocalCommandGroup

type LocalCommandGroup struct {
	Commands   []*LocalCommand
	Expansions *Expansions
}

func (*LocalCommandGroup) PrepToRun

func (lc *LocalCommandGroup) PrepToRun() error

type RemoteCommand

type RemoteCommand struct {
	Id        string
	CmdString string

	Stdout io.Writer
	Stderr io.Writer

	// info necessary for sshing into the remote host
	RemoteHostName string
	User           string
	Options        []string
	Background     bool

	// optional flag for hiding sensitive commands from log output
	LoggingDisabled bool

	// set after the command is started
	Cmd *exec.Cmd
}

func (*RemoteCommand) Run

func (rc *RemoteCommand) Run() error

func (*RemoteCommand) Start

func (rc *RemoteCommand) Start() error

func (*RemoteCommand) Stop

func (rc *RemoteCommand) Stop() error

func (*RemoteCommand) Wait

func (rc *RemoteCommand) Wait() error

type ScpCommand

type ScpCommand struct {
	Id     string
	Source string
	Dest   string

	Stdout io.Writer
	Stderr io.Writer

	// info about the remote host
	RemoteHostName string
	User           string
	Options        []string

	// tells us whether to copy from local to remote or from remote to local
	SourceIsRemote bool

	// set after the command is started
	Cmd *exec.Cmd
}

func (*ScpCommand) Run

func (self *ScpCommand) Run() error

func (*ScpCommand) Start

func (self *ScpCommand) Start() error

func (*ScpCommand) Stop

func (self *ScpCommand) Stop() error

Jump to

Keyboard shortcuts

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