Documentation
¶
Overview ¶
Package provision orchestrates container provisioning steps via zmx. After SSH bootstrap (handled by rc.local), the Runner SSHes into the container as root, installs zmx, and executes named provisioning steps using zmx run. Each step runs in its own pty session, enabling structured status tracking (zmx list), output capture (zmx history), and interactive debugging on failure (zmx attach).
Index ¶
- func Script(steps []Step) string
- func StepNames(steps []Step) []string
- type Executor
- type MockExecutor
- type Runner
- func (r *Runner) HasProvisionScript(ctx context.Context) bool
- func (r *Runner) History(ctx context.Context, name string) (string, error)
- func (r *Runner) IsProvisioned(ctx context.Context) bool
- func (r *Runner) List(ctx context.Context) (string, error)
- func (r *Runner) PollStatus(ctx context.Context, names []string) (string, bool)
- func (r *Runner) Run(ctx context.Context, step Step) error
- func (r *Runner) Wait(ctx context.Context, names ...string) error
- func (r *Runner) WaitProvisioned(ctx context.Context, setStatus func(string))
- type Session
- type Step
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Executor ¶ added in v0.4.0
type Executor interface {
// Exec runs a command and returns its exit code.
Exec(ctx context.Context, command []string) (int, error)
// Output runs a command and returns its stdout.
Output(ctx context.Context, command []string) ([]byte, error)
}
Executor runs commands on a remote host.
type MockExecutor ¶ added in v0.4.0
type MockExecutor struct {
ExecFunc func(ctx context.Context, command []string) (int, error)
OutputFunc func(ctx context.Context, command []string) ([]byte, error)
}
MockExecutor is a test double for Executor.
type Runner ¶
type Runner struct {
Host string
User string // typically "root"
KeyPath string
Log io.Writer
// contains filtered or unexported fields
}
Runner executes and monitors zmx provisioning steps over SSH.
func NewRunnerWith ¶ added in v0.4.0
NewRunnerWith creates a Runner using the provided Executor. This is intended for testing.
func (*Runner) HasProvisionScript ¶
HasProvisionScript checks if the provision script was written to the container.
func (*Runner) IsProvisioned ¶
IsProvisioned checks if the provision sentinel file exists.
func (*Runner) List ¶
List runs zmx list and returns the raw output. The caller can display this directly or parse it for structured status information.
func (*Runner) PollStatus ¶
PollStatus checks zmx list and returns a human-readable status string and whether all expected steps are done. Returns ("", false) if zmx isn't ready yet or the list fails.
func (*Runner) Run ¶
Run starts a provisioning step via zmx run. The command returns immediately; the step executes in the background inside its own pty session.
type Session ¶
type Session struct {
Name string
EndedAt string // unix timestamp or empty if still running
ExitCode string // exit code or empty if still running
}
Session holds parsed fields from a zmx list output line.
func ParseSessions ¶
ParseSessions parses zmx list output into sessions.
type Step ¶
type Step struct {
Name string // zmx session name (e.g., "px-egress")
Script string // shell command to execute inside zmx
Finalize string // optional: runs after ALL steps complete (not tracked by zmx)
}
Step defines a named provisioning task to run via zmx.