Help us shape the future of Go! Take the 2026 Go Developer Survey

assets

package
v1.37.1-stratum.0-rc.2 Latest Latest
Warning

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

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

Documentation

Overview

Package assets stages the payload embedded in the stratum executable onto disk at runtime.

The executable is a normal ELF binary with a ZIP archive concatenated onto the end (see the package target in the repo Makefile). ZIP readers locate the central directory by scanning backwards from EOF, so the archive is found regardless of how much ELF precedes it, and the ELF loader ignores the trailing bytes. That trick is the whole reason one artifact can carry a control plane.

SKE carries the container images in that payload as well as the binaries, so the single artifact is airgap-complete: nothing is fetched from a registry at install time. The archive has two top-level directories:

bin/     component binaries, staged executable
images/  an OCI archive of the pinned image set, staged read-only

Index

Constants

View Source
const (
	BinDir    = "bin"
	ImagesDir = "images"
)

Payload directory names, matching the archive's top-level layout.

Variables

View Source
var DefaultRoot = version.DefaultRoot

DefaultRoot is where the payload is staged. Binaries land in DefaultRoot/bin, images in DefaultRoot/images.

The path itself lives in internal/version, derived from the data root. This name stays for its existing callers and snapshots version.DefaultRoot once at package init: production never reassigns the roots, so the snapshot and the derived path agree, but a test that moves the roots with version.SetRoots moves version.DefaultRoot and NOT this var — read version.DefaultRoot directly when a test-redirectable path is what the caller needs.

View Source
var ErrNoPayload = errors.New("no embedded payload in this executable")

ErrNoPayload reports an executable built without an embedded archive (EMBEDDED_BINS=none). Callers fall back to Lookup.

Functions

func ArchiveImageNames

func ArchiveImageNames(path string) ([]string, error)

ArchiveImageNames returns the image names an OCI image archive's index.json carries, or, for a Docker-format archive (which ctr also imports), its manifest.json RepoTags as containerd names them. It reads only tar headers and those two members.

func ImageNames

func ImageNames(archives []string) (map[string]bool, error)

ImageNames returns every image name the archives carry, as containerd names them on import.

func Lookup

func Lookup(root, name string) (string, error)

Lookup resolves a component binary for a no-payload build: an already-staged file first, then PATH. Used by EMBEDDED_BINS=none builds (dev and OS-packaged variants, where the OS package places the binaries).

func Names

func Names(exePath string) ([]string, error)

Names lists the payload members of the given executable without extracting anything, so `stratum version --components` can report what the artifact carries cheaply.

func Repository

func Repository(name string) string

Repository is an image name without its tag or digest, the form kubelet's preloadedImagesVerificationAllowlist matches.

func Stage

func Stage(root string) ([]string, error)

Stage extracts the whole payload under root, preserving the archive's bin/ and images/ layout, and returns the staged paths relative to root.

Extraction is skipped per file when the destination already has the same size and modification time, which is what makes a restart cheap: the executable's own mtime is stamped onto each staged file, so "already staged by this exact binary" is a two-field comparison rather than a hash of half a gigabyte.

func StageFrom

func StageFrom(exePath, root string) ([]string, error)

StageFrom is Stage with the executable named explicitly: it extracts the ZIP-append payload of the binary at exePath. The upgrade path uses it to stage a staged upgrade binary's payload; it is also what makes staging testable without re-execing the test binary.

func StageFromWithWriter

func StageFromWithWriter(w io.Writer, exePath, root string) ([]string, error)

StageFromWithWriter stages a payload and reports label warnings to w.

func StageWithWriter

func StageWithWriter(w io.Writer, root string) ([]string, error)

StageWithWriter stages this executable's payload and reports label warnings to w.

Types

This section is empty.

Jump to

Keyboard shortcuts

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