teambuild

package
v0.7.2 Latest Latest
Warning

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

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

Documentation

Overview

Package teambuild orchestrates the local `kuke team init --build` path: it walks the FROM directives of the catalog entries a project selected, derives the transitive base-before-leaves build order (the bases base/base-user/ base-root are intermediates that live in the agents source tree, not in images.yaml), and invokes the standalone kukebuild binary once per image into the target realm's containerd namespace. Each image is tagged `kukeon.internal/<name>:<version>` and the `REGISTRY=kukeon.internal` build-arg is threaded so leaf FROMs of the form `${REGISTRY}/base-user:latest` resolve to the just-built in-realm base rather than a real registry pull.

The kukebuild invocation is deliberately distinct from cmd/kuke/build's `kuke build` CLI shim: that shim replaces the process via syscall.Exec so kukebuild's exit code reaches the operator unmediated. The orchestrator here must build N images and then return to the caller (which proceeds to render and apply), so it spawns kukebuild with os/exec and waits for each to complete — exec-and-return, not exec-and-replace.

Step 2 of the build-and-supply epic (#1063, this issue #1064): the build-invoke half. The bind decision (binding the locally-built `kukeon.internal/<name>:<version>` refs into the CellBlueprints instead of the published `entry.Image`) plus the runtime no-pull path for `kukeon.internal/...` refs are step 3 (#1068) and depend on this step's in-realm images.

Index

Constants

View Source
const InternalRegistry = consts.InternalImageRegistry

InternalRegistry is the reserved, non-routable "host" every locally-built kuke image is tagged under. It is ICANN's `.internal` private-use TLD — pulling from it can never accidentally hit a real registry. Leaf Dockerfiles `FROM ${REGISTRY}/base-user:latest` are threaded with this value via `--build-arg REGISTRY=kukeon.internal` so the FROM resolves to the in-realm base just built, rather than the agents source's published default.

Defined as a single source of truth in internal/consts so the build path here, the bind path (internal/teamrender), and the runtime local-only resolver (internal/ctr) cannot drift on the reserved host.

Variables

This section is empty.

Functions

func BuildAll

func BuildAll(
	ctx context.Context,
	cacheDir, sourceRef, realm string,
	leaves []*model.ImageCatalogEntry,
	progressW, stdout, stderr io.Writer,
) error

BuildAll plans the build set and runs each step in order, halting on the first failure. The caller hands the bundle's CacheDir, the source's pinned ref, the target realm, the selected catalog entries, and stdout/ stderr writers; BuildAll handles the FROM-walk, per-step kukebuild invocation, and progress messaging. progressW receives one line per step announcing what is being built before the kukebuild progress stream begins, so an interrupted multi-image build is debuggable from the log.

An empty leaves slice is a no-op — a roster with no harnesses selects no images, so there is nothing to build.

func BuildArgv

func BuildArgv(step Step, realm string) []string

BuildArgv composes the kukebuild argv for a step. argv[0] is the binary name by exec convention. The forwarded flags match cmd/kuke/build's buildArgv shape — `--tag`, `--realm`, `--file`, repeated `--build-arg`s, and the positional context — so the kukebuild surface stays single. build-arg keys are emitted in sorted order so the argv is byte-stable across runs (golang map iteration is randomized).

func Run

func Run(ctx context.Context, step Step, realm string, stdout, stderr io.Writer) error

Run invokes kukebuild for a single step. It looks the binary up on PATH, composes the argv, and spawns it via os/exec with the parent's environment — exec-and-return semantics so the team-init lifecycle can continue after each build. Stdout/stderr are forwarded to the supplied writers (typically the operator's terminal) so kukebuild's progress is visible inline.

Types

type Step

type Step struct {
	// Name is the image's logical identifier — the catalog entry's ref for a
	// leaf, or the base directory name (e.g. `base-user`) for an intermediate.
	// Surfaces in progress logs and the resolved Tag's repo component.
	Name string
	// Version is the tag suffix (e.g. `v1.4.0`, `latest`). For leaves it is
	// the agents source's pinned ref so step 3's bind decision carries a
	// versioned ref into the CellBlueprint; for bases it mirrors the literal
	// tag the leaves' FROM line referenced (typically `latest`).
	Version string
	// Tag is the full image reference the build is tagged with —
	// `kukeon.internal/<Name>:<Version>` — passed to kukebuild's `--tag` flag.
	Tag string
	// Context is the absolute on-disk path to the build context root passed
	// as kukebuild's positional argument.
	Context string
	// Dockerfile is the absolute on-disk path to the Dockerfile. Passed to
	// kukebuild's `--file` flag when set.
	Dockerfile string
	// BuildArgs is the `--build-arg KEY=VALUE` set forwarded verbatim. Plan
	// always seeds `REGISTRY=kukeon.internal` so leaf FROMs of the form
	// `${REGISTRY}/base-user:latest` resolve to the in-realm base.
	BuildArgs map[string]string
	// IsLeaf records whether this step is a catalog leaf (vs. a transitive
	// base intermediate). Diagnostic only — the build invocation is identical.
	IsLeaf bool
}

Step is one image kukebuild builds: the resolved on-disk inputs (context dir + Dockerfile path), the tag the result lands under in the realm namespace, and the build-arg map passed to the Dockerfile frontend. Steps flow base-before-leaves through Plan.

func Plan

func Plan(
	cacheDir, sourceRef string,
	leaves []*model.ImageCatalogEntry,
) ([]Step, error)

Plan resolves the build set for a project's selected catalog entries. For each leaf entry the planner reads its build.context + build.dockerfile, parses the Dockerfile's FROM directives, substitutes ${REGISTRY} with the kukeon.internal host, and follows any FROM that lands under `kukeon.internal/<name>:<tag>` as a transitive in-repo base (`<cacheDir>/harnesses/<name>/Dockerfile`). The walk is iterative and dedupes by image name so a base referenced by N leaves builds once. The returned slice is topologically ordered base-before-leaves so a kukebuild loop building it in order satisfies every FROM by the time the leaf builds.

sourceRef is the agents source's pinned ref (tag/branch/commit value) used as the leaf images' `<version>` tag suffix. cacheDir is the materialized agents source root teamsource produced.

External FROMs (anything not under kukeon.internal — debian:bookworm, docker.io/library/ubuntu, etc.) are pulled by kukebuild from their real registries at build time; the planner records them as inputs but does not produce a Step for them.

Jump to

Keyboard shortcuts

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