provision

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 1, 2026 License: MIT Imports: 7 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Script

func Script(steps []Step) string

Script generates a self-contained provisioning shell script that installs zmx and runs the given steps concurrently. The script is designed to be written to the container rootfs and invoked from rc.local via nohup.

func StepNames

func StepNames(steps []Step) []string

StepNames returns the names of the given steps.

Types

type Runner

type Runner struct {
	Host    string
	User    string // typically "root"
	KeyPath string
	Log     io.Writer
}

Runner executes and monitors zmx provisioning steps over SSH.

func (*Runner) HasProvisionScript

func (r *Runner) HasProvisionScript(ctx context.Context) bool

HasProvisionScript checks if the provision script was written to the container.

func (*Runner) History

func (r *Runner) History(ctx context.Context, name string) (string, error)

History returns the scrollback output of a completed zmx session.

func (*Runner) InstallZmx

func (r *Runner) InstallZmx(ctx context.Context) error

InstallZmx downloads and installs the zmx binary inside the container.

func (*Runner) IsProvisioned

func (r *Runner) IsProvisioned(ctx context.Context) bool

IsProvisioned checks if the provision sentinel file exists.

func (*Runner) List

func (r *Runner) List(ctx context.Context) (string, error)

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

func (r *Runner) PollStatus(ctx context.Context, names []string) (string, bool)

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

func (r *Runner) Run(ctx context.Context, step Step) error

Run starts a provisioning step via zmx run. The command returns immediately; the step executes in the background inside its own pty session.

func (*Runner) Wait

func (r *Runner) Wait(ctx context.Context, names ...string) error

Wait blocks until all named zmx sessions complete.

func (*Runner) WaitProvisioned

func (r *Runner) WaitProvisioned(ctx context.Context, setStatus func(string))

WaitProvisioned polls until provisioning completes, calling setStatus with zmx step progress along the way. Returns immediately if no provisioning is expected or already complete.

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

func ParseSessions(raw string) []Session

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.

func Steps

func Steps(egress string, devtools bool) []Step

Steps returns the provisioning steps to execute based on configuration. All steps run concurrently via zmx. Steps with a Finalize script have that script executed after ALL steps complete — this allows egress lockdown to be deferred until devtools finishes downloading.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL