Documentation
¶
Overview ¶
Package env is the Go port of .lok8s/libs/env — environment and service configuration. Merges services.yaml + services.<config>.yaml and generates the Tilt overlay kustomization (clusters/<domain>/artifacts/ kustomization.yaml). Driven by the Tilt extension via the hidden `lo env` command.
The deep-merge itself still shells out to yq (`yq eval-all '. as $item ireduce ({}; . * $item )'`) through the Runner seam — `lo env services` output is a user-visible stream the Tiltfile consumes, and only the same binary guarantees byte parity. Field EXTRACTION from the merged YAML is native (ordered yaml.Node walk with yq's `//`-swallows-false semantics).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrHandled = ui.ErrHandled // one sentinel for every package; see internal/ui
ErrHandled marks a failure whose message was already printed in the bash format; callers exit non-zero without printing anything further.
Functions ¶
func BareEnvsubst ¶
BareEnvsubst is GNU gettext envsubst with no SHELL-FORMAT (the bash pipeline's bare `envsubst`): every `${NAME}` and identifier-boundary bare `$NAME` reference is replaced with the variable's value — undefined vars become the empty string — while anything that is not a plain reference (`${X:-y}`, `${arr[0]}`, `$$`) passes through untouched. Single pass; substituted values are not rescanned.
Types ¶
type Context ¶
type Context struct {
Paths *config.Paths
Runner execx.Runner
Out io.Writer
ErrOut io.Writer
// Domain is the resolved active domain (bash: the dynamically scoped
// `${domain:-${DOMAIN_NAME:-lok8s.dev}}`).
Domain string
// BuildArtifacts is the build::artifacts seam (nil → build.Artifacts
// with the spec-driven split, exactly like `lo build`'s core).
BuildArtifacts func() error
// Pull drains the cache queue (bash: image::cache --all) — wired by the
// CLI layer to the image package, keeping env free of an import cycle.
Pull func() error
}
Context carries one env-command invocation.
func (*Context) Kustomization ¶
Kustomization generates clusters/<domain>/artifacts/kustomization.yaml (bash: env::kustomization) — the Tilt overlay that wraps the SINGLE domain artifact (clusters/<domain>/artifacts.yaml, built by build.Artifacts) and layers the services.yaml image swaps on top. Tilt builds this dir into one pool it partitions via filter_yaml() (see .lok8s/tilt/Tiltfile). NOTE it deliberately writes INTO the artifacts/ directory the split emit preserves (env's overlay kustomization.yaml, capi.yaml and .cache-queue live as files directly under artifacts/ — see build.Artifacts' pruneStaleArtifactDirs).
func (*Context) Services ¶
Services prints the merged service configuration (bash: env::services). Merges services.yaml (committed) + services.<config>.yaml (override). Returns empty YAML ({}) when no services.yaml exists (projects that manage k8s manifests directly without the services abstraction).