Documentation ¶
Index ¶
- Variables
- type FakeCommandRunner
- func (f *FakeCommandRunner) Copy(file assets.CopyableFile) error
- func (f *FakeCommandRunner) DumpMaps(w io.Writer)
- func (f *FakeCommandRunner) GetFileToContents(filename string) (string, error)
- func (f *FakeCommandRunner) Remove(file assets.CopyableFile) error
- func (f *FakeCommandRunner) RunCmd(cmd *exec.Cmd) (*RunResult, error)
- func (f *FakeCommandRunner) SetCommandToOutput(cmdToOutput map[string]string)
- func (f *FakeCommandRunner) SetFileToContents(fileToContents map[string]string)
- type RunResult
- type Runner
- type SSHRunner
Constants ¶
This section is empty.
Variables ¶
var ( // ErrPrefix notes an error ErrPrefix = "! " // OutPrefix notes output OutPrefix = "> " )
Functions ¶
This section is empty.
Types ¶
type FakeCommandRunner ¶
type FakeCommandRunner struct {
// contains filtered or unexported fields
}
FakeCommandRunner mocks command output without running the Commands
It implements the CommandRunner interface and is used for testing.
func NewFakeCommandRunner ¶
func NewFakeCommandRunner() *FakeCommandRunner
NewFakeCommandRunner returns a new FakeCommandRunner
The expected output of commands should be set with SetCommandToOutput
func (*FakeCommandRunner) Copy ¶
func (f *FakeCommandRunner) Copy(file assets.CopyableFile) error
Copy adds the filename, file contents key value pair to the stored map.
func (*FakeCommandRunner) DumpMaps ¶
func (f *FakeCommandRunner) DumpMaps(w io.Writer)
DumpMaps prints out the list of stored commands and stored filenames.
func (*FakeCommandRunner) GetFileToContents ¶
func (f *FakeCommandRunner) GetFileToContents(filename string) (string, error)
GetFileToContents stores the file to contents map for the FakeCommandRunner
func (*FakeCommandRunner) Remove ¶
func (f *FakeCommandRunner) Remove(file assets.CopyableFile) error
Remove removes the filename, file contents key value pair from the stored map
func (*FakeCommandRunner) RunCmd ¶ added in v1.5.2
func (f *FakeCommandRunner) RunCmd(cmd *exec.Cmd) (*RunResult, error)
RunCmd implements the Command Runner interface to run a exec.Cmd object
func (*FakeCommandRunner) SetCommandToOutput ¶
func (f *FakeCommandRunner) SetCommandToOutput(cmdToOutput map[string]string)
SetCommandToOutput stores the file to contents map for the FakeCommandRunner
func (*FakeCommandRunner) SetFileToContents ¶
func (f *FakeCommandRunner) SetFileToContents(fileToContents map[string]string)
SetFileToContents stores the file to contents map for the FakeCommandRunner
type RunResult ¶ added in v1.5.2
type RunResult struct { Stdout bytes.Buffer Stderr bytes.Buffer ExitCode int Args []string // the args that was passed to Runner }
RunResult holds the results of a Runner
type Runner ¶
type Runner interface { // RunCmd runs a cmd of exec.Cmd type. allowing user to set cmd.Stdin, cmd.Stdout,... // not all implementors are guaranteed to handle all the properties of cmd. RunCmd(cmd *exec.Cmd) (*RunResult, error) // Copy is a convenience method that runs a command to copy a file Copy(assets.CopyableFile) error // Remove is a convenience method that runs a command to remove a file Remove(assets.CopyableFile) error }
Runner represents an interface to run commands.
func NewExecRunner ¶ added in v1.7.0
func NewExecRunner() Runner
NewExecRunner returns a kicRunner implementor of runner which runs cmds inside a container
func NewKICRunner ¶ added in v1.7.0
NewKICRunner returns a kicRunner implementor of runner which runs cmds inside a container
type SSHRunner ¶
type SSHRunner struct {
// contains filtered or unexported fields
}
SSHRunner runs commands through SSH.
It implements the CommandRunner interface.
func NewSSHRunner ¶
NewSSHRunner returns a new SSHRunner that will run commands through the ssh.Client provided.
func (*SSHRunner) Copy ¶
func (s *SSHRunner) Copy(f assets.CopyableFile) error
Copy copies a file to the remote over SSH.