Documentation
¶
Overview ¶
Package cellconfig holds the identity primitives for a daemon-stored CellConfig (kind: CellConfig, issue #624, phase 4b-i of #423): the back-reference label a materialized cell carries, the deterministic stable-name derivation, and the slot-fill validation that checks a Config's repo/secret fills against the referenced blueprint's declared structural slots. It is the config analog of the cellblueprint package's materialization helpers; the runtime state machine that consumes these primitives (and the `kuke run -c` verb that drives it) lands in #625.
Index ¶
- Constants
- func ApplyEnvOverrides(doc *v1beta1.CellDoc, envArgs []string)
- func MaterializeWithName(cfg v1beta1.CellConfigDoc, bp v1beta1.CellBlueprintDoc, name string) (v1beta1.CellDoc, error)
- func MergeEnv(specEnv, envArgs []string) []string
- func Prefix(cfg v1beta1.CellConfigDoc) string
- func ResolveAttachableContainerIndex(spec v1beta1.CellSpec) int
- func ValidateSlotFill(cfg v1beta1.CellConfigDoc, bp v1beta1.CellBlueprintDoc) error
Constants ¶
const LabelConfig = "kukeon.io/config"
LabelConfig is the cell *lineage* label recording the CellConfig a cell was materialized from, the config analog of cellprofile.LabelProfile and cellblueprint.LabelBlueprint. Set on every cell that `kuke run <config>` materializes (#625) so operators can enumerate all of a Config's spawns with `kuke get cells -l kukeon.io/config=<name>`.
The relationship is 1:N, not identity (epic:cell-identity #1021): a single Config may stamp many cells, and the cell's identity is its own name on the CellDoc — not this label. The persisted Spec.Provenance block carries the same binding reference in a typed, machine-readable form for re-resolution; this label is the operator-facing, `-l`-selectable projection of it.
Variables ¶
This section is empty.
Functions ¶
func ApplyEnvOverrides ¶
ApplyEnvOverrides bakes the validated `--env KEY=VALUE` per-cell overrides into the materialised CellDoc (issue #1023). Two effects, mirroring the `kuke run --env` provenance contract (#1021) but persisting rather than riding the transport-only Spec.RuntimeEnv:
- the overrides are merged into the attachable container's persisted Env (ResolveAttachableContainerIndex picks the target the same way `kuke run` would attach), winning over any value the Config's spec.values resolved for the same key — so the override survives the stopped-cell persist and takes effect on the later `kuke start`;
- the same entries are recorded verbatim in Spec.Provenance.EnvOverrides, the P1 materialization-input record P5 re-resolves against.
A nil/empty envArgs is a no-op. When no container is attachable the overrides are still recorded in provenance (the operator's intent is preserved) but have nowhere to bake, mirroring the runtime path's silent no-op on a non-attachable cell.
Shared by `kuke create cell --env`, the clone path, and the reconcile re-resolve path (epic:cell-identity P5, #1024) so all three re-apply the overlay through one precedence-identical helper.
func MaterializeWithName ¶
func MaterializeWithName( cfg v1beta1.CellConfigDoc, bp v1beta1.CellBlueprintDoc, name string, ) (v1beta1.CellDoc, error)
MaterializeWithName converts a CellConfig + its referenced CellBlueprint into a runtime CellDoc (issue #625), naming the cell `name` verbatim. It is the config analog of cellblueprint.MaterializeWithName, but the two channels differ:
- Scalar values come from cfg.Spec.Values (not --param CLI args); the env fallback is intentionally absent because a Config's values are the persistent record of what the operator chose at apply time. Resolution goes through cellblueprint.ResolveConfig (the lenient channel, #1124): a machine-generated Config carries operator facts the blueprint never declares as parameters, so undeclared keys are tolerated and substituted rather than rejected with the interactive `--param` typo-strictness.
- Structural slot fills (repo URLs, secret sources) come from cfg.Spec.Repos and cfg.Spec.Secrets, keyed by slot name. Unknown fills and unfilled required slots are rejected via ValidateSlotFill; optional unfilled slots are dropped from the materialized container.
The materialized cell carries the cellconfig.LabelConfig lineage label (AC of #625) plus every label the operator set on cfg.Metadata.Labels, and a Spec.Provenance block recording the Config binding it was stamped from (issue #1021). The cell's scope coordinates come from the Config's metadata, not the blueprint's, so a Config in one realm may instantiate a Blueprint in another (cross-realm references are explicitly supported by CellConfigBlueprintRef).
The cell name is supplied by the caller — materialization no longer derives it from cfg.Metadata.Name (epic:cell-identity #1021 severs that assumption; the cell's identity is the CellDoc, and the Config name is demoted to lineage). Callers resolve the name via the unified generator (naming.AllocCellName over cellconfig.Prefix, #1022): an explicit name is used verbatim, an omitted one becomes a generated `<prefix>-<6hex>`. An empty name is the caller's responsibility (it yields an empty-named cell that fails downstream validation) — materialization intentionally does not paper over it by reaching back to the Config name.
func MergeEnv ¶
MergeEnv layers the validated env overrides on top of a container's existing Env. For each KEY in envArgs, any specEnv entry with the same KEY is dropped (the override wins); surviving spec entries keep their order, then the override entries follow in their input order. Mirrors the runner-side mergeRuntimeEnv merge semantics so a `create cell --env` override and a `run --env` override resolve identically. Never mutates the input slices.
func Prefix ¶
func Prefix(cfg v1beta1.CellConfigDoc) string
Prefix resolves the cell-name prefix the unified generator uses for a cell materialized from this Config (epic:cell-identity #1022): Spec.Prefix when set, else the config's metadata.name. It mirrors cellblueprint.Prefix.
This is the prefix-default helper that replaces the retired StableName identity pin. A Config is no longer a 1:1 identity (#1020 moves identity onto the CellDoc): a `create cell --from-config` with no explicit name yields a fresh `<prefix>-<6hex>` cell, so Prefix supplies only the leading segment, never the whole deterministic name.
func ResolveAttachableContainerIndex ¶
ResolveAttachableContainerIndex returns the index of the container `kuke run` would attach to (issue #834's runtime-env target), or -1 when none qualifies. Precedence mirrors the daemon-side resolveAttachableContainerID and the CLI-side pickAttachTarget:
- Spec.Tty.Default, when it names an existing non-root container;
- the first non-root container with Attachable=true, in declaration order;
- -1 when no container qualifies.
func ValidateSlotFill ¶
func ValidateSlotFill(cfg v1beta1.CellConfigDoc, bp v1beta1.CellBlueprintDoc) error
ValidateSlotFill checks a CellConfig's structural slot fills against the slots the referenced blueprint declares (issue #624). Matching is by slot name, across all of the blueprint's containers:
- a repo slot is a blueprint repo with no inline url (a url'd repo is a scalar-mode value, not a fillable slot);
- every blueprint secret slot is structural (the blueprint never carries the secret source).
It enforces the AC's two gates: a Config that fills a slot the blueprint does not declare is an error (ErrConfigUnknown{Repo,Secret}Slot), and a *required* slot the blueprint declares that the Config leaves unfilled is an error (ErrConfigRequiredSlotUnfilled). A slot is treated as required if any declaration of that name across the blueprint's containers is required.
Types ¶
This section is empty.