Documentation ¶
Index ¶
- Variables
- type FakeCommandRunner
- func (f *FakeCommandRunner) Copy(file assets.CopyableFile) error
- func (f *FakeCommandRunner) CopyFrom(file assets.CopyableFile) error
- func (f *FakeCommandRunner) DumpMaps(w io.Writer)
- func (f *FakeCommandRunner) GetFileToContents(filename string) (string, error)
- func (f *FakeCommandRunner) ReadableFile(_ string) (assets.ReadableFile, 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)
- func (f *FakeCommandRunner) StartCmd(cmd *exec.Cmd) (*StartedCmd, error)
- func (f *FakeCommandRunner) WaitCmd(sc *StartedCmd) (*RunResult, error)
- type RunResult
- type Runner
- type SSHRunner
- func (s *SSHRunner) Copy(f assets.CopyableFile) error
- func (s *SSHRunner) CopyFrom(f assets.CopyableFile) error
- func (s *SSHRunner) ReadableFile(sourcePath string) (assets.ReadableFile, error)
- func (s *SSHRunner) Remove(f assets.CopyableFile) error
- func (s *SSHRunner) RunCmd(cmd *exec.Cmd) (*RunResult, error)
- func (s *SSHRunner) StartCmd(cmd *exec.Cmd) (*StartedCmd, error)
- func (s *SSHRunner) WaitCmd(sc *StartedCmd) (*RunResult, error)
- type StartedCmd
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) CopyFrom ¶ added in v1.23.0
func (f *FakeCommandRunner) CopyFrom(file assets.CopyableFile) error
CopyFrom copy content from file 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) ReadableFile ¶ added in v1.25.0
func (f *FakeCommandRunner) ReadableFile(_ string) (assets.ReadableFile, error)
ReadableFile implements interface (without implementation)
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
func (*FakeCommandRunner) StartCmd ¶ added in v1.16.0
func (f *FakeCommandRunner) StartCmd(cmd *exec.Cmd) (*StartedCmd, error)
StartCmd implements the Command Runner interface to start a exec.Cmd object
func (*FakeCommandRunner) WaitCmd ¶ added in v1.16.0
func (f *FakeCommandRunner) WaitCmd(sc *StartedCmd) (*RunResult, error)
WaitCmd implements the Command Runner interface to wait until a started exec.Cmd object finishes
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) // StartCmd starts a cmd of exec.Cmd type. // This func in non-blocking, use WaitCmd to block until complete. // Not all implementors are guaranteed to handle all the properties of cmd. StartCmd(cmd *exec.Cmd) (*StartedCmd, error) // WaitCmd will prevent further execution until the started command has completed. WaitCmd(startedCmd *StartedCmd) (*RunResult, error) // Copy is a convenience method that runs a command to copy a file Copy(assets.CopyableFile) error // CopyFrom is a convenience method that runs a command to copy a file back CopyFrom(assets.CopyableFile) error // Remove is a convenience method that runs a command to remove a file Remove(assets.CopyableFile) error // ReadableFile open a remote file for reading ReadableFile(sourcePath string) (assets.ReadableFile, error) }
Runner represents an interface to run commands.
func NewExecRunner ¶ added in v1.7.0
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.
func (*SSHRunner) CopyFrom ¶ added in v1.23.0
func (s *SSHRunner) CopyFrom(f assets.CopyableFile) error
CopyFrom copies a file from the remote over SSH.
func (*SSHRunner) ReadableFile ¶ added in v1.25.0
func (s *SSHRunner) ReadableFile(sourcePath string) (assets.ReadableFile, error)
ReadableFile returns assets.ReadableFile for the sourcePath (via `stat` command)
func (*SSHRunner) Remove ¶
func (s *SSHRunner) Remove(f assets.CopyableFile) error
Remove runs a command to delete a file on the remote.
func (*SSHRunner) RunCmd ¶ added in v1.5.2
RunCmd implements the Command Runner interface to run a exec.Cmd object
type StartedCmd ¶ added in v1.16.0
type StartedCmd struct {
// contains filtered or unexported fields
}
StartedCmd holds the contents of a started command