runtime

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: MPL-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheSubpath added in v0.0.5

func CacheSubpath(target string) string

CacheSubpath derives the stable per-target cache key: the first 8 hex chars of the sha256 of the target path. Hashing keeps the key order-independent and collision-safe as profiles add or remove cache paths.

func DerivedRef

func DerivedRef(repoTag string) string

DerivedRef normalizes a RepoTag from ImageList into the canonical tpod/packages:<hash> form, or "" if the tag doesn't belong to a derived image. Engines qualify RepoTags with their registry (docker.io/, localhost/, quay.io/, ...), so the match is on the reference path, not a string prefix — a locally built image keeps its tag even though its hash is what identifies it.

func DerivedTag

func DerivedTag(baseID string, packages []string, repos map[string]Repo) string

DerivedTag returns the content-addressed tag tpod lays on a derived image built from baseID with the given packages and apt repos. The tag is the first 16 hex chars of a sha256 over baseID, the sorted package list, and (when non-empty) the sorted canonical repo descriptors:

no repos:   sha256(baseID \x00 sorted(packages).join(\x01))
with repos: sha256(baseID \x00 sorted(packages).join(\x01) \x00 sorted(canonical-repos).join(\x02))

The repos segment is appended only when non-empty, so a packages-only profile keeps the byte-identical pre-repos hash and its cached derived image survives the upgrade. Pure; does not touch the Docker daemon. Package and repo order is canonicalised before hashing so catalog authors can't trigger rebuilds by reordering.

Returns "" when both packages and repos are empty — the prepare path short-circuits and no derived image is built.

func QueryRootless

func QueryRootless(ctx context.Context, cli *client.Client) (bool, error)

QueryRootless makes a raw GET to /info and parses the "rootless" field from the JSON response. Podman's Docker-compatible API includes this field; Docker's does not (it's absent, so json.Unmarshal leaves it as false). Exported so the doctor package can reuse it (Plan 3) without duplication.

func ResolveImageID

func ResolveImageID(ctx context.Context, cli *client.Client, ref string) (string, error)

ResolveImageID returns the content-addressed image-config SHA of the locally-present image referenced by ref. Used as the hash input for DerivedTag and for invalidating derived images when the local base image changes. Callers handle a missing-local-image error by skipping the profile's contribution to the "used" derived-tag set (no local base ⇒ no possible derived image).

func SELinuxEnforcing added in v0.0.2

func SELinuxEnforcing() bool

SELinuxEnforcing reports whether SELinux is enforcing on this host. Exported for tpod doctor, which mirrors the launch-time detection.

Types

type CacheSpec

type CacheSpec struct {
	// Name is the shared volume for the whole cache entry. On engines that
	// honor volume subpaths each target mounts Name with VolumeOptions.Subpath
	// set to Subpath; otherwise a dedicated volume Name-<Subpath> backs each
	// target.
	Name   string
	Target string
	// Subpath is the stable per-target key (sha256 of the target path,
	// truncated). It keeps the subdirectory/fallback-volume stable and
	// order-independent as profiles add or remove paths.
	Subpath string
}

type DeviceSpec

type DeviceSpec struct {
	Container string
	Host      string
	Perms     string
	Cgroup    bool
}

type DockerRuntime

type DockerRuntime struct {
	// contains filtered or unexported fields
}

func NewDockerRuntime

func NewDockerRuntime() (*DockerRuntime, error)

func (*DockerRuntime) DetectMode

func (d *DockerRuntime) DetectMode(ctx context.Context) (workspace.Mode, error)

DetectMode queries the engine's /info endpoint and checks for the Podman "rootless" field. The Docker SDK's types.Info does not map this field, so we make a raw HTTP request and parse the JSON ourselves. Spec §5.4.

func (*DockerRuntime) Prepare

func (d *DockerRuntime) Prepare(ctx context.Context, spec Spec, w ProgressWriter) (string, error)

func (*DockerRuntime) Run

func (d *DockerRuntime) Run(ctx context.Context, spec Spec) (int, error)

type FakeRuntime

type FakeRuntime struct {
	PreparedSpec *Spec
	RanSpec      *Spec
	PrepareErr   error
	PrepareImage string
	RunErr       error
	ExitCode     int
}

FakeRuntime is a test helper that records Prepare/Run calls. Exported so pkg/tpod tests can import it without redefining.

func (*FakeRuntime) Prepare

func (f *FakeRuntime) Prepare(ctx context.Context, spec Spec, w ProgressWriter) (string, error)

func (*FakeRuntime) Run

func (f *FakeRuntime) Run(ctx context.Context, spec Spec) (int, error)

type FileSpec

type FileSpec struct {
	Target  string
	Content string
	Mode    uint32
}

type MountSpec

type MountSpec struct {
	Target   string
	Source   string
	ReadOnly bool
	Optional bool
	Create   bool
}

type NoopProgressWriter

type NoopProgressWriter struct{}

func (NoopProgressWriter) WriteProgress

func (NoopProgressWriter) WriteProgress(string)

type PortSpec

type PortSpec struct {
	HostIP    string
	HostPort  string
	Container string
	Protocol  string
}

type ProgressWriter

type ProgressWriter interface {
	WriteProgress(line string)
}

type Repo

type Repo struct {
	ExtRepo    string
	URL        string
	KeyURL     string
	Suites     string
	Components string
}

Repo mirrors profile.Repo: a single extra apt source, either an extrepo catalog name (ExtRepo) or a fully inline custom repo (URL/KeyURL/...). Fields are duplicated (not the profile type) so the runtime package stays independent of the profile package.

type Runtime

type Runtime interface {
	Prepare(ctx context.Context, spec Spec, w ProgressWriter) (string, error)
	Run(ctx context.Context, spec Spec) (int, error)
}

type Spec

type Spec struct {
	ProfileName string
	Image       string
	Packages    []string
	Repos       map[string]Repo
	Files       []FileSpec
	Command     []string
	Mounts      []MountSpec
	PortSpecs   []PortSpec
	DeviceSpecs []DeviceSpec
	Env         map[string]string
	Tools       map[string]string
	Caches      []CacheSpec
	Network     string
	Labels      map[string]string
	Workspace   WorkspaceSpec
	TTY         string
	RuntimeHome string
}

type WorkspaceSpec

type WorkspaceSpec struct {
	HostPath string
	Target   string
	Mode     workspace.Mode
}

Jump to

Keyboard shortcuts

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