Documentation
¶
Overview ¶
Package setup implements host detection and bootstrap for `dexaflow setup` and `dexaflow doctor`: it determines the platform, which dependencies are present, and which operating tier is achievable, preferring relocatable downloads into ~/.dexaflow over system package managers.
Index ¶
- func EnsureMonaco(ctx context.Context, client *http.Client, home string, ...) (string, error)
- func EnsurePostgres(ctx context.Context, o EnsureOpts) (string, error)
- func EnsurePython(ctx context.Context, o EnsureOpts) (string, error)
- func ExtractFS(fsys fs.FS, dest string) error
- func GenerateHumanPassword() (string, error)
- func MonacoDir(home string) string
- func ProvisionVenv(ctx context.Context, run Runner, pythonPath, venvDir string, ...) (string, error)
- func PythonCandidates() []string
- type EnsureOpts
- type PostgresBuild
- type Probe
- type PythonBuild
- type Report
- type Runner
- type Tier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureMonaco ¶
func EnsureMonaco(ctx context.Context, client *http.Client, home string, logf func(string, ...any)) (string, error)
EnsureMonaco makes the pinned Monaco bundle available under MonacoDir(home) and returns that directory. It is a no-op when already provisioned; otherwise it downloads the pinned npm tarball, verifies its SHA-256, and extracts only the min/vs subtree.
func EnsurePostgres ¶
func EnsurePostgres(ctx context.Context, o EnsureOpts) (string, error)
EnsurePostgres returns the bin directory of a managed relocatable PostgreSQL (Home/postgres/bin), downloading + verifying + extracting the pinned build if it is not already present. Unlike Python there is NO system fallback: Lite manages its own Postgres so the version and on-disk layout are predictable and — the point of Fase 2 — it needs no Docker. The data directory and process lifecycle are the caller's concern (see the Lite runner).
func EnsurePython ¶
func EnsurePython(ctx context.Context, o EnsureOpts) (string, error)
EnsurePython returns the path to a usable Python 3.11: a system interpreter if one is on PATH, the managed relocatable CPython if already installed under Home, or a freshly downloaded-and-verified pinned build otherwise. The managed build is extracted to Home/python (the archive's top-level "python/" dir).
func ExtractFS ¶
ExtractFS writes every file in fsys into dest, preserving the directory structure. It is used to materialize the embedded Python sources into ~/.dexaflow so a binary-only install can pip-install them.
func GenerateHumanPassword ¶
GenerateHumanPassword returns a short, human-readable admin password: a random word followed by 2–4 random digits, lowercase letters and digits only, at most ten characters. It is easy to write down and unambiguous, while still drawn from crypto/rand so it is not guessable.
func MonacoDir ¶
MonacoDir returns the directory the pinned Monaco bundle is served from (home/assets/monaco/<version>). The editor loads /ide/vs from <dir>/vs.
func ProvisionVenv ¶
func ProvisionVenv(ctx context.Context, run Runner, pythonPath, venvDir string, pipPackages []string) (string, error)
ProvisionVenv creates a virtualenv at venvDir using pythonPath, then pip installs pipPackages into it, and returns the venv's interpreter path. The heavy work (notably the parser's Airflow dependency) happens once; reruns are the caller's responsibility to gate. The runner is injected for testing.
func PythonCandidates ¶
func PythonCandidates() []string
PythonCandidates returns the interpreter binary names Detect probes for, in preference order. It exists so `dexaflow lite` and `dexaflow validate` resolve an interpreter from the SAME list `dexaflow setup` and `dexaflow doctor` report on (#1092): the two used to disagree, so doctor could name a python3.13 that dev never probed for. The slice is copied because callers are in another package and a shared backing array would let one of them reorder the gate's literal.
Types ¶
type EnsureOpts ¶
type EnsureOpts struct {
Home string // the managed root, e.g. ~/.dexaflow
GOOS string
GOARCH string
Libc string
LookPath func(string) (string, error)
Stat func(string) (os.FileInfo, error)
Client *http.Client
Logf func(string, ...any) // optional progress callback
}
EnsureOpts configures EnsurePython.
type PostgresBuild ¶
PostgresBuild is a relocatable PostgreSQL release asset and its checksum.
func ResolvePostgres ¶
func ResolvePostgres(goos, goarch, libc string) (PostgresBuild, error)
ResolvePostgres returns the pinned relocatable PostgreSQL asset for the host, or an error if the platform is unsupported (e.g. Windows, where WSL2 is the path).
type Probe ¶
type Probe struct {
GOOS string
GOARCH string
LookPath func(string) (string, error) // os/exec.LookPath
Stat func(string) (fs.FileInfo, error)
Getwd func() (string, error)
}
Probe carries the host facts Detect needs. The function fields are injected so detection is testable without touching the real filesystem or PATH.
type PythonBuild ¶
PythonBuild is a relocatable CPython release asset and its expected checksum.
func ResolvePython ¶
func ResolvePython(goos, goarch, libc string) (PythonBuild, error)
ResolvePython returns the pinned relocatable CPython asset for the host, or an error if the platform is unsupported (e.g. Windows, where WSL2 is the path).
type Report ¶
type Report struct {
OS string
Arch string
Libc string // "glibc" or "musl" on linux; empty on darwin
PythonAvailable bool // a usable Python 3.11+ interpreter is on PATH
PythonPath string // path to the chosen interpreter; empty when none is on PATH
// Python311Path is a host python3.11 SPECIFICALLY, empty when there is none.
//
// It is separate from PythonPath because the two answer different questions
// and the answers disagree on a very common machine. PythonPath answers
// "what can parse a dag.py", and 3.12 or 3.13 can, because the Lite parser
// shim is stdlib-only (ADR 0024). This field answers "will `dexaflow setup`
// have to download a managed CPython", and only a 3.11 avoids that, because
// setup.EnsurePython resolves the host interpreter with LookPath("python3.11")
// and nothing else qualifies.
//
// Reporting only the first made `doctor` and `setup --dry-run` tell a host
// with just 3.12 that its system Python would be used and nothing
// downloaded, and then setup downloaded (#1224). Neither component was
// wrong on its own; they were answering different questions in the same
// sentence.
Python311Path string
Docker bool
K3d bool
Kubectl bool
UnderMnt bool // cwd under /mnt (WSL 9p mount): inotify hot-reload is unreliable
Tier Tier
}
Report is the outcome of Detect: the platform, which tools are present, and the highest achievable tier.
type Runner ¶
Runner runs an external command; injected so venv provisioning is testable without a real Python.
type Tier ¶
type Tier int
Tier is an operating mode, ordered by the infrastructure it needs.
const ( // TierSubprocess runs the agent directly on the host with no isolation — the // dev-only escape hatch (ADR 0015). Fastest loop; no Docker or Kubernetes. TierSubprocess Tier = iota // TierK8s runs each task in an ephemeral pod via client-go, on a local // single-node cluster (k3d) or a real cluster. The sole container path // (ADR 0015); Docker is only the engine that hosts the local cluster, never // an executor itself. TierK8s )