Documentation
¶
Overview ¶
Package command provides a uniform interface for executing commands on local and remote hosts.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommandResult ¶
type Executor ¶
type Executor interface {
Exec(ctx context.Context, command string) (*CommandResult, error)
}
type LocalExecutor ¶
type LocalExecutor struct {
// contains filtered or unexported fields
}
func NewLocalExecutor ¶
func NewLocalExecutor(config LocalExecutorConfig) *LocalExecutor
func (*LocalExecutor) Exec ¶
func (e *LocalExecutor) Exec(ctx context.Context, command string) (*CommandResult, error)
type LocalExecutorConfig ¶
type LocalExecutorConfig struct {
RunAsRoot bool
}
type MockExecutor ¶
type MockExecutor struct {
Rules []MockRule
}
func NewMockExecutor ¶
func NewMockExecutor(rules []MockRule) *MockExecutor
func (*MockExecutor) Exec ¶
func (e *MockExecutor) Exec(ctx context.Context, command string) (*CommandResult, error)
type MockRule ¶
type MockRule struct {
// CommandContains is a string that must be present in the command for the rule to match.
CommandContains string
// Stdout is the simulated standard output.
Stdout string
// Stderr is the simulated standard error.
Stderr string
// ExitCode is the simulated exit code.
ExitCode int
}
type RemoteExecutor ¶
type RemoteExecutor struct {
// contains filtered or unexported fields
}
func NewRemoteExecutor ¶
func NewRemoteExecutor(config RemoteExecutorConfig) *RemoteExecutor
func (*RemoteExecutor) Exec ¶
func (e *RemoteExecutor) Exec(ctx context.Context, command string) (*CommandResult, error)
Click to show internal directories.
Click to hide internal directories.