Documentation
¶
Overview ¶
Package cellprofile loads per-user CellProfile templates from $HOME/.kuke/profiles.d/*.yaml (or $KUKE_PROFILES_DIR) and materializes them into CellDocs that `kuke run -p` then drives along the same path as `-f`.
Index ¶
- Constants
- func List(dir string) ([]v1beta1.CellProfileDoc, error)
- func Load(dir, name string) (*v1beta1.CellProfileDoc, error)
- func LoadResolved(dir, name string, cliParams map[string]string, ...) (*v1beta1.CellProfileDoc, error)
- func Materialize(profile *v1beta1.CellProfileDoc) (v1beta1.CellDoc, error)
- func MaterializeWithName(profile *v1beta1.CellProfileDoc, nameOverride string) (v1beta1.CellDoc, error)
- func MergeParams(base, overrides map[string]string) map[string]string
- func ParseParamArgs(args []string) (map[string]string, error)
- func ParseParamFile(path string) (map[string]string, error)
- func ResolveDir() (string, error)
Constants ¶
const DefaultDirSuffix = ".kuke/profiles.d"
DefaultDirSuffix is appended to $HOME when KUKE_PROFILES_DIR is unset. Matches sbsh's `~/.sbsh/profiles.d` layout.
const EnvProfilesDir = "KUKE_PROFILES_DIR"
EnvProfilesDir is the env var that overrides the default user profiles directory. Picked up by ResolveDir; takes precedence over $HOME/.kuke/profiles.d.
const LabelProfile = "kukeon.io/profile"
LabelProfile is the cell label that records the CellProfile a cell was materialized from. Set on every cell produced by Materialize so operators can list all instances with `kuke get cells -l kukeon.io/profile=<name>`.
Variables ¶
This section is empty.
Functions ¶
func List ¶
func List(dir string) ([]v1beta1.CellProfileDoc, error)
List returns every parseable CellProfile in dir, sorted by metadata.name. Used by both the `-p` autocomplete handler and the fallback name lookup in Load. Files that fail to parse are skipped silently — the operator finds out via Load when they actually try to use the broken profile.
func Load ¶
func Load(dir, name string) (*v1beta1.CellProfileDoc, error)
Load reads $dir/<name>.yaml (or its .yml sibling) and returns the parsed profile. When neither exists, it falls back to scanning every *.yaml / *.yml file in the directory and matching on metadata.name — the file basename is the convenient case but not authoritative, so two profiles can share a directory regardless of how they were named on disk.
`${KEY}` references in the body remain literal — substitution is a `kuke run -p`-time concern. Use LoadResolved when the caller has --param values to apply.
Wraps errdefs.ErrProfileNotFound when the name does not resolve, including the directory in the error so the operator knows where to drop the file.
func LoadResolved ¶ added in v0.4.0
func LoadResolved( dir, name string, cliParams map[string]string, lookupEnv func(string) (string, bool), ) (*v1beta1.CellProfileDoc, error)
LoadResolved is Load + parameter substitution. Resolution order per declared parameter: cliParams[k] > parameters[k].default > lookupEnv(k). When lookupEnv is nil the env fallback is skipped — useful for tests and for callers that want to keep substitution narrow (e.g., a daemon that must not draw from the user's shell).
Returns errdefs.ErrProfileInvalid wrapped when:
- the profile body references `${KEY}` for a KEY not declared in spec.parameters[] (typo at install time);
- cliParams contains a key not declared in spec.parameters[] (typo at call time);
- a parameter declared `required: true` resolves to no value.
Empty string is a valid resolved value: only "unset" — every provider declines — triggers the required-vs-default decision.
func Materialize ¶
func Materialize(profile *v1beta1.CellProfileDoc) (v1beta1.CellDoc, error)
Materialize converts a CellProfile into a CellDoc suitable for the same path `kuke run -f` drives. CellProfile is always a template: every call returns a cell named `<prefix>-<6hex>`, where prefix is spec.prefix when set and metadata.name otherwise. Singleton workloads belong on the Cell kind. The realm/space/stack triple is taken from the profile spec verbatim — callers layer --realm/--space/--stack flag overrides separately, mirroring the existing -f resolution. Every produced cell also carries the kukeon.io/profile=<metadata.name> label so the set of cells materialized from a profile is queryable via `kuke get cells -l`.
func MaterializeWithName ¶ added in v0.4.0
func MaterializeWithName(profile *v1beta1.CellProfileDoc, nameOverride string) (v1beta1.CellDoc, error)
MaterializeWithName is Materialize with an explicit cell-name override — used by `kuke run -p ... --name <override>`. When nameOverride is non-empty (after trim) it replaces the generated `<prefix>-<6hex>` name verbatim, so callers can give the cell a deterministic identity (e.g., the orchestrator dispatching `crew-dev-354` so it can later attach by name). When empty, behavior matches Materialize.
func MergeParams ¶ added in v0.4.0
MergeParams returns the union of base and overrides, with overrides winning on duplicate keys. Used by `kuke run` to layer --param on top of --param-file (CLI flag is later-binding than the file).
func ParseParamArgs ¶ added in v0.4.0
ParseParamArgs validates a slice of `KEY=VALUE` strings (from --param) and returns the equivalent map. Empty values are allowed (`KEY=` → ""); missing `=` errors. Duplicate keys: last occurrence wins, matching `docker run -e` semantics.
func ParseParamFile ¶ added in v0.4.0
ParseParamFile reads path and parses it as a list of `KEY=VALUE` lines. Blank lines and lines whose first non-whitespace character is `#` are skipped (POSIX-ish comment shape). Same KEY=VALUE rules as ParseParamArgs.
Values are taken verbatim after the first `=` — no quote stripping, no shell expansion. Callers that need shell semantics should pre-render their own file. Trailing CR is stripped so files written on Windows host editors still parse cleanly.
func ResolveDir ¶
ResolveDir returns the active profiles directory: $KUKE_PROFILES_DIR if set, otherwise $HOME/.kuke/profiles.d. The directory is not required to exist — callers either tolerate ENOENT (List) or surface ProfileNotFound (Load).
Types ¶
This section is empty.