Documentation
¶
Overview ¶
Package envrun brings a task's VM workspace environment up and down (P1 §4, workspace-run.md §internal/agent/envrun): it runs spec.environment's setup and up scripts, waits for its ready checks, and runs its down script at the end. It implements pipeline.Environment; only the VM workspace (vmrun) uses it.
Index ¶
Constants ¶
const ( // DefaultReadyTimeout bounds the ready checks when ready.timeout is unset. DefaultReadyTimeout = 15 * time.Minute // KindImagesDir is where the warm base saves warm.kindImages as archives // (workspace-host.md §The VM steps); FACTORY_KIND_IMAGES names it when it holds one. KindImagesDir = "/var/lib/factory/kind-images" // EnvKindImages is the scripts' variable for KindImagesDir. EnvKindImages = "FACTORY_KIND_IMAGES" // MaxLog caps out/environment.log; past it a [truncated] line ends it. MaxLog = 10 << 20 // MaxTail is how much of a failed script's output its error carries. MaxTail = 8 << 10 )
Defaults and bounds.
Variables ¶
This section is empty.
Functions ¶
func VersionVar ¶
VersionVar is the scripts' and the harness's variable for a spec.versions component: FACTORY_VERSION_ and the component upper-cased, with "-" as "_".
Types ¶
type Options ¶
type Options struct {
// StateDir holds what the runner writes outside the workspace: the scripts, under env/.
StateDir string
// DownTimeout bounds the down script. Default: pipeline.StackDownTimeout.
DownTimeout time.Duration
// KindImages is the kind image archives' directory. Default: KindImagesDir.
KindImages string
// Clock times the steps and the ready checks. Default: clock.Real.
Clock clock.Clock
// Logger logs the steps. Default: discard.
Logger *slog.Logger
// OnStep, when set, is called after each sub-step that ran (environment.setup, .up,
// .ready, .down) with its duration and its redacted error.
OnStep func(name string, d time.Duration, err error)
// Redact removes secrets from the scripts' output and the errors. Default:
// pipeline.RedactShapes (the VM holds no token of its own).
Redact func(string) string
}
Options configure a Runner. StateDir is required.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner is one run's environment: Up once, then Down once. It implements pipeline.Environment.
func (*Runner) Down ¶
Down implements pipeline.Environment: it runs the down script once, bounded by DownTimeout and ctx, whichever ends first, and closes the log. Its error is the environment.down step's, never the run's outcome.
func (*Runner) Up ¶
func (r *Runner) Up(ctx context.Context, ws harness.Workspace, t v1alpha1.Task) (map[string]string, error)
Up implements pipeline.Environment: it writes the scripts, runs setup and up in ws.Root, and waits for ready. It returns the exposes and FACTORY_VERSION_<COMPONENT> for each spec.versions entry.