cell

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ImageContainerID is the id of the single user container synthesized for
	// the imperative `--image` source. The runner synthesizes the root
	// container at create time (the path docs/examples/hello-world.yaml relies
	// on), so the synthesized cell carries only this one user entry.
	ImageContainerID = "main"

	// ImageDefaultCommand is the entrypoint baked into the synthesized
	// container when `--command` is omitted: an interactive shell, so a bare
	// `kuke run --image <ref>` drops the operator into a usable terminal.
	ImageDefaultCommand = "/bin/sh"
)
View Source
const AnnotationSourceCell = "kukeon.io/source-cell"

AnnotationSourceCell is the inert provenance annotation a clone carries, recording the cell it was forked from (epic:cell-identity #1073). Distinct from the load-bearing kukeon.io/config / kukeon.io/blueprint lineage labels: no reconcile or selector path keys off it, DiffCell does not compare it, and it pins no identity — it is debug/grooming metadata only. Stored under the `kukeon.io/` prefix (not the `.kukeon.io` controller-managed suffix) so it reads as cell-authored provenance.

View Source
const ImageNameFallbackPrefix = "cell"

ImageNameFallbackPrefix is the seed ImageNamePrefix returns when an image ref has no usable short name (e.g. it is all separators).

Variables

This section is empty.

Functions

func ImageNamePrefix added in v0.9.0

func ImageNamePrefix(image string) string

ImageNamePrefix derives the `<prefix>-<6hex>` name prefix for a cell synthesized from an image ref, used when `kuke run --image` is invoked without an explicit `--name`. It takes the image's final path segment with any tag/digest stripped (`docker.io/library/alpine:3` → `alpine`, `localhost:5000/myapp:dev` → `myapp`), lower-cases it, and replaces any character outside [a-z0-9-] with `-`. An image that reduces to nothing usable falls back to ImageNameFallbackPrefix so the generator always has a seed.

func Materialize added in v0.6.0

func Materialize(
	cmd *cobra.Command, client kukeonv1.Client, flags SourceFlags, scope ScopeVars,
) (v1beta1.CellDoc, error)

Materialize resolves the source binding named by flags (--from-blueprint / --from-config / --clone) and returns the fully-finalized CellDoc — name allocated, scope overlaid, provenance + overrides applied — WITHOUT persisting it. `kuke create cell` persists the doc stopped via MaterializeCell; `kuke run` create+starts it via CreateCell then attaches. This single entrypoint is the shared materialization function of epic:cell-identity #1025 (AC#4): the two verbs cannot drift because the materialised doc comes from the same code. The caller is responsible for the existence pre-check + persist (materialiseAndPersist for create cell; CreateCell for run).

func NewCellCmd

func NewCellCmd() *cobra.Command

func PrintCellResult

func PrintCellResult(cmd *cobra.Command, result kukeonv1.CreateCellResult)

PrintCellResult is exported for testing purposes.

func RegisterSourceFlags added in v0.6.0

func RegisterSourceFlags(cmd *cobra.Command)

RegisterSourceFlags registers the cell-source flag definitions (--from-blueprint, --from-config, --clone, --param, --param-file, --env, --ignore-disk-pressure), their mutual-exclusion, and their shell-completion funcs on cmd. Both `kuke create cell` and `kuke run` call it so the two verbs share one flag-definition set and cannot drift (epic:cell-identity #1025).

It deliberately does NOT call viper.BindPFlag: viper is a process-global singleton and two commands binding the same key would race (last-registered wins). `kuke create cell` adds its own KUKE_CREATE_CELL_* binds after calling this (for env-var fallback); `kuke run` reads the flags directly via cmd.Flags(). Scope flags (--realm/--space/--stack) are NOT registered here — they bind command-specific viper keys and each command owns its own.

func SynthesizeFromImage added in v0.9.0

func SynthesizeFromImage(image, command string) (v1beta1.CellDoc, error)

SynthesizeFromImage builds a minimal single-container CellDoc from an imperative image ref — the shared synthesis behind `kuke run --image` and `kuke create cell --image` (epic:first-run #1244/#1245). The cell carries one attachable user container running the given image; `command` overrides its entrypoint, falling back to ImageDefaultCommand when empty. The runner synthesizes the root container at create time.

The returned doc has no name and no realm/space/stack scope — the caller finalizes both (run/create resolve the name via the shared allocator and overlay scope from --realm/--space/--stack or session defaults) before persisting. Keeping naming + scope out of synthesis is what lets the two verbs share one entrypoint without colliding on a command-specific flag set.

func ValidateOverrideSymmetry added in v0.6.0

func ValidateOverrideSymmetry(flags SourceFlags) error

ValidateOverrideSymmetry enforces the per-path --param/--env override symmetry shared by `kuke create cell` and `kuke run` (epic:cell-identity #1023/#1025):

  • --param/--param-file are rejected with --from-config (a CellConfig carries its own spec.values);
  • --env is rejected with --from-blueprint (its symmetric counterpart — materialise from a Config to layer env overrides).

The clone source kind carries its own per-lineage variants of these checks (cloneFromConfig / cloneFromBlueprint) because the rejected flag depends on the source cell's recorded bindingKind, not on a CLI flag — so this validator is a no-op for clone. Materialize calls it up front, which is why `kuke run` (which feeds Materialize a SourceFlags it built itself) inherits the same rules without re-implementing them.

Types

type MockControllerKey

type MockControllerKey struct{}

MockControllerKey is used to inject a mock kukeonv1.Client via context in tests.

type ScopeVars added in v0.6.0

type ScopeVars struct {
	Realm *config.Var
	Space *config.Var
	Stack *config.Var
}

ScopeVars names the command-specific scope viper Vars the materialize path reads to resolve binding-lookup scope. An unset --space/--stack defaults to the var's "default" (issue #1156) so the lookup hits the full default scope; a realm-scoped Blueprint/Config stays reachable via an explicit empty `--space "" --stack ""`. `kuke create cell` passes its KUKE_CREATE_CELL_* vars; `kuke run` passes its KUKE_RUN_* vars. Threading the Vars in (rather than hard-coding KUKE_CREATE_CELL_*) is what lets the two verbs share one Materialize entrypoint without colliding on a global viper key (epic:cell-identity #1025).

type SourceFlags added in v0.6.0

type SourceFlags struct {
	Name          string
	Realm         string
	Space         string
	Stack         string
	BlueprintName string
	ConfigName    string
	// CloneSource is the source cell name passed via `--clone <src>` (the
	// third source kind, epic:cell-identity #1073). When set, the cell is
	// forked from the source cell's Spec.Provenance rather than resolved from a
	// Blueprint/Config named on the CLI.
	CloneSource string
	ParamArgs   []string
	ParamFile   string
	// EnvArgs holds the validated `--env KEY=VALUE` per-cell overrides. Valid
	// with --from-config only (parity with --param on --from-blueprint); baked
	// into the attachable container's env and recorded in
	// Spec.Provenance.EnvOverrides. Issue #1023.
	EnvArgs []string
	// IgnoreDiskPressure threads `--ignore-disk-pressure` onto the
	// transport-only Spec.IgnoreDiskPressure field so the daemon's
	// CreateCell guard is bypassed for this invocation. Issue #1035.
	IgnoreDiskPressure bool
}

SourceFlags is the validated bundle of source-flag values the materialize path consumes. It is shared between `kuke create cell` (which persists the materialised doc stopped via MaterializeCell) and `kuke run` (which create+starts it via CreateCell then attaches) — the two verbs build a SourceFlags from their own flag surfaces and feed it to the single Materialize entrypoint so the materialisation cannot drift (epic:cell-identity #1025, AC#4). Fields are exported so the run package can populate them.

Jump to

Keyboard shortcuts

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