engine

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Overview

On non-Linux platforms, and on Linux built with CGO_ENABLED=0 (which cannot link libcontainer's namespace bootstrap), the container lifecycle is unsupported. These stubs let the package compile and cross-compile for all targets; every method reports ErrUnsupported.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupported = errors.New("spod container execution requires Linux user namespaces")

Functions

func DefaultRoot

func DefaultRoot() (string, error)

DefaultRoot returns the platform-standard location for spod's storage: $XDG_DATA_HOME/spod/storage (defaulting to ~/.local/share/spod/storage) on Linux and other Unix systems, ~/Library/Application Support/spod/storage on macOS, and %LOCALAPPDATA%\spod\storage on Windows. SPOD_ROOT overrides the location and must be absolute.

func Init

func Init()

Init is a no-op on platforms and builds that cannot execute containers (non-Linux, or Linux built with CGO_ENABLED=0, which cannot link the libcontainer nsenter bootstrap). Calling it first in main() remains safe.

func ValidateName

func ValidateName(name string) error

Types

type BuildOptions added in v0.3.0

type BuildOptions struct {
	// Context is the build context directory COPY and ADD read from.
	Context string
	// File is the Containerfile path; empty selects Containerfile, then
	// Dockerfile, in Context.
	File string
	// Tag is the reference the built image is stored under.
	Tag string
	// BuildArgs override ARG defaults.
	BuildArgs map[string]string
	// Target selects the stage to build; empty builds the last one.
	Target string
}

BuildOptions describes a Containerfile build.

type Container

type Container struct {
	Name       string
	Image      string
	Status     string
	Entrypoint []string
	PID        int
	Created    time.Time
	Options    RunOptions
}

type Engine

type Engine struct {
	Root string
}

Engine is a daemonless, per-user image and container store.

func New

func New(root string) (*Engine, error)

func (*Engine) Build added in v0.3.0

func (e *Engine) Build(context.Context, BuildOptions, IO) (*Image, error)

Build is unsupported without the Linux container lifecycle: RUN executes in a container.

func (*Engine) Discard

func (e *Engine) Discard(path string) error

Discard retains removed resources in the store's trash rather than deleting them.

func (*Engine) Exec

func (*Engine) Export

func (e *Engine) Export(ctx context.Context, name string, out io.Writer) error

Export requires the Linux container runtime, which records containers and their root filesystems.

func (*Engine) Images

func (e *Engine) Images() ([]Image, error)

Images lists only complete published images.

func (*Engine) Import

func (e *Engine) Import(ctx context.Context, ref string, archive io.Reader) (*Image, error)

Import builds a stored image from a plain filesystem tar, such as one produced by Export, so it can serve as the base image of other containers. The archive becomes the image's single layer; no entrypoint, environment, or history is inferred beyond a default PATH. The archive is buffered while the layer digest is computed. Import works on every platform; only running the resulting containers requires Linux.

func (*Engine) ImportOCI added in v0.2.0

func (e *Engine) ImportOCI(ctx context.Context, ref, path string) (*Image, error)

ImportOCI stores an image tarball under ref. Both common save formats are accepted: the OCI layout (podman save --format oci-archive) and the docker-save layout (docker save). Unlike Import, the archive carries the image's real layers and configuration, so the stored image behaves exactly like the source: entrypoint, environment, and history included. The archive must contain a single-platform image matching the host.

func (*Engine) Inspect

func (e *Engine) Inspect(context.Context, string) (*Container, error)

func (*Engine) InspectImage

func (e *Engine) InspectImage(ref string) (*Image, error)

InspectImage reads local metadata without contacting a registry.

func (*Engine) List

func (e *Engine) List(context.Context) ([]Container, error)

func (*Engine) PrepareRootfs

func (e *Engine) PrepareRootfs(ctx context.Context, ref, dest string) (_ *Image, retErr error)

PrepareRootfs creates an independent writable filesystem, never hardlinking files to the shared cache. dest must not exist, or must be an empty directory on the storage filesystem. The returned Image.Rootfs points to dest.

func (*Engine) Pull

func (e *Engine) Pull(ctx context.Context, ref string) (*Image, error)

Pull downloads a Linux image for the host architecture without a daemon. A cached reference is reused; remove it explicitly to refresh a mutable tag.

func (*Engine) Remove

func (e *Engine) Remove(context.Context, string, bool) error

func (*Engine) RemoveImage

func (e *Engine) RemoveImage(ref string) error

RemoveImage retains the image in trash and refuses references used by a container. Unreadable container metadata fails closed.

func (*Engine) Rename

func (e *Engine) Rename(context.Context, string, string) error

func (*Engine) Run

func (e *Engine) Run(context.Context, RunOptions, IO) (int, error)

func (*Engine) Start

func (e *Engine) Start(context.Context, string, IO) (int, error)

func (*Engine) Stop

type ExecOptions

type ExecOptions struct {
	Command []string
	Env     []string
	WorkDir string
	User    string
	TTY     bool
}

type IO

type IO struct {
	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer
}

type Image

type Image struct {
	Reference string
	Digest    string
	Rootfs    string
	Config    v1.Config
	Created   time.Time
	Platform  v1.Platform
}

Image describes an image and its unpacked filesystem. Pull and InspectImage return an immutable shared Rootfs; PrepareRootfs returns the writable copy.

type Lifecycle

Lifecycle is implemented directly by Engine on Linux and returns ErrUnsupported elsewhere.

type Mount

type Mount struct {
	Source   string
	Target   string
	ReadOnly bool
}

type RunOptions

type RunOptions struct {
	Name        string
	Image       string
	Command     []string
	Entrypoint  []string
	Env         []string
	WorkDir     string
	User        string
	Hostname    string
	Mounts      []Mount
	Labels      map[string]string
	TTY         bool
	Interactive bool
	Remove      bool
	Network     string
	// UserNS selects the user namespace mapping: "" maps the caller to
	// container root; "keep-id" maps the caller to its own UID/GID and
	// container root to a subordinate ID, like podman --userns=keep-id.
	UserNS string
}

Jump to

Keyboard shortcuts

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