Documentation
¶
Index ¶
- func CacheSubpath(target string) string
- func DerivedRef(repoTag string) string
- func DerivedTag(baseID string, packages []string, repos map[string]Repo) string
- func QueryRootless(ctx context.Context, cli *client.Client) (bool, error)
- func ResolveImageID(ctx context.Context, cli *client.Client, ref string) (string, error)
- func SELinuxEnforcing() bool
- type CacheSpec
- type DeviceSpec
- type DockerRuntime
- type FakeRuntime
- type FileSpec
- type MountSpec
- type NoopProgressWriter
- type PortSpec
- type ProgressWriter
- type Repo
- type Runtime
- type Spec
- type WorkspaceSpec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CacheSubpath ¶ added in v0.0.5
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 ¶
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 ¶
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 ¶
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 ¶
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 DockerRuntime ¶
type DockerRuntime struct {
// contains filtered or unexported fields
}
func NewDockerRuntime ¶
func NewDockerRuntime() (*DockerRuntime, error)
func (*DockerRuntime) DetectMode ¶
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)
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)
type NoopProgressWriter ¶
type NoopProgressWriter struct{}
func (NoopProgressWriter) WriteProgress ¶
func (NoopProgressWriter) WriteProgress(string)
type ProgressWriter ¶
type ProgressWriter interface {
WriteProgress(line string)
}
type Repo ¶
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 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
}