Documentation ¶
Index ¶
- func Run(runner Runner, conditionRunner Runner, commandChecker Checker, stdio Stdio, ...) error
- type Checker
- type CmdRun
- type Command
- type CommandChecker
- type ConditionRunner
- type ContainerProcess
- type ContainerRunner
- type ExecCommandContext
- type OSProcess
- type Process
- type ProcessRegistry
- type Runner
- type Stdio
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Run ¶
func Run( runner Runner, conditionRunner Runner, commandChecker Checker, stdio Stdio, args []string, postStartCommandName string, postStartCommandArgs []string, postStartConditionCommandName string, postStartConditionCommandArgs []string, ) error
Run implements the logic for the container-run CLI command.
Types ¶
type Checker ¶
Checker is the interface that wraps the basic Check method.
type CmdRun ¶
type CmdRun func( runner Runner, conditionRunner Runner, commandChecker Checker, stdio Stdio, args []string, postStartCommandName string, postStartCommandArgs []string, postStartConditionCommandName string, postStartConditionCommandArgs []string, ) error
CmdRun represents the signature for the top-level Run command.
type Command ¶
Command represents a command to be run.
type CommandChecker ¶
type CommandChecker struct {
// contains filtered or unexported fields
}
CommandChecker satisfies the Checker interface.
func NewCommandChecker ¶
func NewCommandChecker( osStat func(string) (os.FileInfo, error), execLookPath func(file string) (string, error), ) *CommandChecker
NewCommandChecker constructs a new CommandChecker.
func (*CommandChecker) Check ¶
func (cc *CommandChecker) Check(command string) bool
Check checks if command exists as a file or in $PATH.
type ConditionRunner ¶
type ConditionRunner struct {
// contains filtered or unexported fields
}
ConditionRunner satisfies the Runner interface. It represents a runner for a post-start pre-condition.
func NewConditionRunner ¶
func NewConditionRunner( sleep func(time.Duration), execCommandContext func(context.Context, string, ...string) *exec.Cmd, ) *ConditionRunner
NewConditionRunner constructs a new ConditionRunner.
func (*ConditionRunner) Run ¶
func (cr *ConditionRunner) Run( command Command, stdio Stdio, ) (Process, error)
Run is not implemented.
func (*ConditionRunner) RunContext ¶
func (cr *ConditionRunner) RunContext( ctx context.Context, command Command, _ Stdio, ) (Process, error)
RunContext runs a condition until it succeeds or the context times out. The process is never returned. A context timeout makes RunContext to return the error.
type ContainerProcess ¶
type ContainerProcess struct {
// contains filtered or unexported fields
}
ContainerProcess satisfies the Process interface.
func NewContainerProcess ¶
func NewContainerProcess(process OSProcess) *ContainerProcess
NewContainerProcess constructs a new ContainerProcess.
func (*ContainerProcess) Signal ¶
func (p *ContainerProcess) Signal(sig os.Signal) error
Signal sends a signal to the process. If the process is not running anymore, it's no-op.
type ContainerRunner ¶
type ContainerRunner struct { }
ContainerRunner satisfies the Runner interface.
func NewContainerRunner ¶
func NewContainerRunner() *ContainerRunner
NewContainerRunner constructs a new ContainerRunner.
type ExecCommandContext ¶
type ExecCommandContext interface {
CommandContext(ctx context.Context, name string, arg ...string) *exec.Cmd
}
ExecCommandContext wraps exec.CommandContext.
type OSProcess ¶
OSProcess is the interface that wraps the methods for *os.Process.
type Process ¶
Process is the interface that wraps the Signal and Wait methods of a process.
type ProcessRegistry ¶
ProcessRegistry handles all the processes.
func NewProcessRegistry ¶
func NewProcessRegistry() *ProcessRegistry
NewProcessRegistry constructs a new ProcessRegistry.
func (*ProcessRegistry) HandleSignals ¶
func (pr *ProcessRegistry) HandleSignals(sigs <-chan os.Signal, errors chan<- error)
HandleSignals handles the signals channel and forwards them to the registered processes.
func (*ProcessRegistry) Register ¶
func (pr *ProcessRegistry) Register(p Process) int
Register registers a process in the registry and returns how many processes are registered.
func (*ProcessRegistry) SignalAll ¶
func (pr *ProcessRegistry) SignalAll(sig os.Signal) []error
SignalAll sends a signal to all registered processes.