Documentation
¶
Index ¶
- Constants
- func AllocCellName(explicit, prefix string, exists func(string) (bool, error)) (string, error)
- func BuildContainerdID(spaceName, stackName, cellName, containerName string) (string, error)
- func BuildRootContainerdID(spaceName, stackName, cellName string) (string, error)
- func BuildSpaceNetworkName(realmName, spaceName string) (string, error)
- func GenerateCellName(prefix string) (string, error)
- func RandomHexSuffix(n int) (string, error)
- func ValidateHierarchyName(kind, name string) error
- func ValidateRealmName(name string) error
Constants ¶
const DefaultCellNameSuffixBytes = 3
DefaultCellNameSuffixBytes is the canonical entropy width for the `<prefix>-<6hex>` suffix appended to generated cell names by `kuke run -b`, `-p`, and `-c -g`. 3 bytes → 6 lowercase hex chars; matches K8s `generateName`'s suffix shape closely enough that the names read familiar at a glance.
const MaxCellNameAllocAttempts = 64
MaxCellNameAllocAttempts bounds the suffix-collision retry loop in AllocCellName. A DefaultCellNameSuffixBytes-wide (24-bit) suffix makes a single collision astronomically unlikely, so the bound is a safety net against a pathological run rather than an expected hot path. It is sized to match the retry budget of the clone-era `<src>-<N>` gap-fill allocator this generator supersedes (epic:cell-identity #1022).
Variables ¶
This section is empty.
Functions ¶
func AllocCellName ¶ added in v0.6.0
AllocCellName resolves the final name for a cell about to be materialized (epic:cell-identity #1022):
- A non-empty explicit name is used verbatim. The caller's persist layer rejects an in-scope collision — an explicitly named create is not an idempotent attach.
- An empty explicit name yields a generated "<prefix>-<6hex>" that does not collide per exists, regenerating the suffix up to MaxCellNameAllocAttempts times before giving up.
exists reports whether a cell of the candidate name already lives in the target scope; callers build it over the daemon's GetCell view. A nil exists disables the collision probe (single-shot generation) for pure callers with no client.
func BuildContainerdID ¶
BuildContainerdID constructs a container containerd ID using hierarchical format. Format: {spaceName}__{stackName}__{cellName}__{containerName} Validates that all parameters are non-empty.
func BuildRootContainerdID ¶
BuildRootContainerdID constructs a root container containerd ID using hierarchical format. Format: {spaceName}__{stackName}__{cellName}__root Validates that all parameters are non-empty.
func BuildSpaceNetworkName ¶
BuildSpaceNetworkName constructs the canonical network name for a space.
func GenerateCellName ¶ added in v0.6.0
GenerateCellName returns "<prefix>-<6hex>" with a fresh DefaultCellNameSuffixBytes-wide random suffix — the single generated cell-name shape shared by every materialization source kind (epic:cell-identity #1022 retires the per-kind generators: blueprint's inline `<prefix>-<6hex>`, the config StableName pin, and the clone `<src>-<N>` counter). Callers resolve prefix from Spec.Prefix with a metadata.name fallback (see cellconfig.Prefix / cellblueprint.Prefix).
func RandomHexSuffix ¶ added in v0.6.0
RandomHexSuffix returns n cryptographically-random bytes hex-encoded as a lowercase string of length 2n, suitable as a name suffix. Callers wrap any error with their own context (which document the suffix is for).
func ValidateHierarchyName ¶ added in v0.3.0
ValidateHierarchyName rejects space, stack, cell, and container names that would corrupt downstream resources, the same way ValidateRealmName guards realm names. Two characters are blocked:
- "_" collides with the containerd container-ID separator ({space}_{stack}_{cell}_{container}) built by BuildContainerdID. A name containing "_" produces an ambiguous ID that the inverse parser cannot round-trip back to its hierarchy components.
- "/" injects extra path components into the cgroup path (/kukeon/{realm}/{space}/{stack}/{cell}/...).
Empty / whitespace-only names are also rejected so callers have a single entrypoint. Callers that need to surface a "required" error per kind should check emptiness and return their own sentinel before invoking this.
The kind argument ("space", "stack", "cell", "container") is included in the error message so the operator knows which input was rejected.
func ValidateRealmName ¶ added in v0.3.0
ValidateRealmName rejects realm names that would corrupt downstream resources. Two characters are blocked today:
- "_" collides with the containerd container-ID separator ({space}_{stack}_{cell}_{container}) and would break the parser that splits IDs back into hierarchy components.
- "/" injects extra path components into the cgroup path (/kukeon/{realm}/{space}/...).
Empty names are also rejected for callers that want a single entrypoint; callers that need a separate "required" error should keep using errdefs.ErrRealmNameRequired before invoking this.
Types ¶
This section is empty.