env

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: MIT Imports: 12 Imported by: 0

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

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

func BareEnvsubst(data []byte) []byte

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

func (c *Context) Kustomization(ctx context.Context, noBuild, pull bool) error

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

func (c *Context) Services(ctx context.Context, onlyServices, onlyRegistry bool) error

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).

func (*Context) ServicesRaw

func (c *Context) ServicesRaw(ctx context.Context) ([]byte, error)

ServicesRaw returns the merged services env as bytes — the capture form other libs consume (bash: `merged=$(env::services 2>/dev/null)`; callers set ErrOut to io.Discard for the same silencing).

Jump to

Keyboard shortcuts

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