Documentation
¶
Overview ¶
Package envmap flattens a resolved Layer-1 chain into a merged KEY=VALUE environment for the populator (cenvkit run / cenvkit env). It is the no-docker "local arm" of the same chain: pure Go, importing internal/engine for the ONE shared expansion primitive (engine.Flatten) so run/env, env-debug and `docker compose config` all resolve ${VAR} identically (spec §5c, MF4).
envmap itself imports NO compose-go — the seam (only internal/engine touches compose-go) is preserved. It owns the shell-wins overlay and the output formatting (the parts that are pure string handling).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Emit ¶
Emit writes the chain-derived keys of r in the requested format, key-sorted (r.ChainKeys is already sorted). Values come from r.Full so a shell override of a chain key is reflected. The emitted set is BOUNDED to chain keys (spec §5e) — the full inherited process env is never dumped.
All three formats are written to be safe to consume: `dotenv` round-trips compose-go's own parser; `shell` is safe to `eval`; `json` is standard JSON.
Types ¶
type Format ¶
type Format string
Format selects an env emission encoding for `cenvkit env`.
func ParseFormat ¶
ParseFormat validates a --format value.
type Resolved ¶
type Resolved struct {
Full map[string]string // process env + chain (shell-wins); run execs with this
ChainKeys []string // sorted keys the chain contributed; env emits only these
}
Resolved is the flattened chain environment. Full is the complete process env with the chain values overlaid SHELL-WINS (what `cenvkit run` execs with). ChainKeys is the sorted set of keys the chain itself contributed — `cenvkit env` emits ONLY these (bounded, reproducible: it must not dump the whole inherited process env into CI logs, spec §5e). The emitted value for a chain key is Full[k], so a shell override of a chain key is reflected.
func Resolve ¶
Resolve flattens the existence-filtered chain file list into Resolved.
- expand=true → ${VAR}/${VAR:-default} expand via engine.Flatten (dotenv.GetEnvFromFile); unset ${VAR} with no default → empty (compose parity), not an error.
- expand=false → literal values, ${...} unexpanded (engine.ParseOrderedLiteral under the hood).
Shell-wins applies IDENTICALLY on both paths: --no-expand suppresses only the ${VAR} expansion, never the overlay (spec §5b). files MUST be existence-filtered (chain.Resolve drops missing); a vanished file (TOCTOU) surfaces as Flatten's error and is fatal to the caller.