envrun

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: AGPL-3.0 Imports: 22 Imported by: 0

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

View Source
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

func VersionVar(component string) string

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 New

func New(o Options) (*Runner, error)

New checks the options and fills in the defaults.

func (*Runner) Down

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

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

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.

Jump to

Keyboard shortcuts

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