container

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultSocketPath = "/run/containerd/containerd.sock"
	DefaultNamespace  = "default"

	BackendContainerd = "containerd"
	BackendApple      = "apple"
	BackendDocker     = "docker"
)
View Source
const (
	// StorageKeyLabel stores the runtime-specific active storage key on backends
	// whose container metadata does not expose one natively.
	StorageKeyLabel = "memoh.storage_key"
)

Variables

View Source
var (
	ErrInvalidArgument = errors.New("invalid argument")
	ErrNotSupported    = errors.New("operation not supported on this backend")
	ErrNotFound        = errors.New("not found")
	ErrAlreadyExists   = errors.New("already exists")
	ErrConflict        = errors.New("conflict")
	ErrRuntime         = errors.New("runtime operation failed")
)

Functions

func IsAlreadyExists

func IsAlreadyExists(err error) bool

func IsConflict

func IsConflict(err error) bool

func IsNotFound

func IsNotFound(err error) bool

func IsRuntime

func IsRuntime(err error) bool

func ResolveConfSource

func ResolveConfSource(dataDir string) (string, error)

ResolveConfSource returns a host path to mount as /etc/resolv.conf.

Types

type CPUMetrics

type CPUMetrics struct {
	UsagePercent      float64
	UsageNanoseconds  uint64
	UsageNanocores    uint64
	UserNanoseconds   uint64
	KernelNanoseconds uint64
}

type CommitSnapshotRequest

type CommitSnapshotRequest struct {
	Source StorageRef
	Target SnapshotRef
}

type ContainerInfo

type ContainerInfo struct {
	ID         string
	Image      string
	Labels     map[string]string
	StorageRef StorageRef
	Runtime    RuntimeInfo
	CreatedAt  time.Time
	UpdatedAt  time.Time
}

type ContainerMetrics

type ContainerMetrics struct {
	SampledAt time.Time
	CPU       *CPUMetrics
	Memory    *MemoryMetrics
}

type ContainerService

type ContainerService interface {
	CreateContainer(ctx context.Context, req CreateContainerRequest) (ContainerInfo, error)
	GetContainer(ctx context.Context, id string) (ContainerInfo, error)
	ListContainers(ctx context.Context) ([]ContainerInfo, error)
	DeleteContainer(ctx context.Context, id string, opts *DeleteContainerOptions) error
	ListContainersByLabel(ctx context.Context, key, value string) ([]ContainerInfo, error)
}

ContainerService groups container metadata and creation operations.

type ContainerSpec

type ContainerSpec struct {
	Cmd               []string
	Env               []string
	WorkDir           string
	User              string
	Mounts            []MountSpec
	DNS               []string
	NetworkJoinTarget NetworkJoinTarget
	AddedCapabilities []string
	// CDIDevices contains fully-qualified CDI device names such as
	// "nvidia.com/gpu=0" or "amd.com/gpu=0".
	CDIDevices []string
	TTY        bool
}

type CreateContainerRequest

type CreateContainerRequest struct {
	ID              string
	ImageRef        string
	ImagePullPolicy string
	StorageRef      StorageRef
	ResourceLimits  ResourceLimits
	Labels          map[string]string
	Spec            ContainerSpec
}

type DeleteContainerOptions

type DeleteContainerOptions struct {
	CleanupSnapshot bool
}

type DeleteImageOptions

type DeleteImageOptions struct {
	Synchronous bool
}

type DeleteTaskOptions

type DeleteTaskOptions struct {
	Force bool
}

type ImageInfo

type ImageInfo struct {
	Name string
	ID   string
	Tags []string
}

type ImageService

type ImageService interface {
	PullImage(ctx context.Context, ref string, opts *PullImageOptions) (ImageInfo, error)
	GetImage(ctx context.Context, ref string) (ImageInfo, error)
	ListImages(ctx context.Context) ([]ImageInfo, error)
	DeleteImage(ctx context.Context, ref string, opts *DeleteImageOptions) error
	// ResolveRemoteDigest fetches only the manifest digest from the registry
	// without downloading any layers. Returns ErrNotSupported on backends that
	// have no concept of a remote registry.
	ResolveRemoteDigest(ctx context.Context, ref string) (string, error)
}

ImageService groups image and registry operations.

type LayerStatus

type LayerStatus struct {
	Ref    string `json:"ref"`
	Offset int64  `json:"offset"`
	Total  int64  `json:"total"`
}

type ListSnapshotsRequest

type ListSnapshotsRequest struct {
	Driver string
}

type ListTasksOptions

type ListTasksOptions struct {
	ContainerID string
}

type MemoryMetrics

type MemoryMetrics struct {
	UsageBytes   uint64
	LimitBytes   uint64
	UsagePercent float64
}

type MountInfo

type MountInfo struct {
	Type    string
	Source  string
	Target  string
	Options []string
}

type MountSpec

type MountSpec struct {
	Destination string
	Type        string
	Source      string
	Options     []string
}

func TimezoneSpec

func TimezoneSpec() ([]MountSpec, []string)

TimezoneSpec returns environment variables that propagate the host timezone.

type NetworkJoinTarget

type NetworkJoinTarget struct {
	Kind  string
	Value string
	PID   uint32
}

NetworkJoinTarget is an adapter-provided handle for runtimes that can attach another workload to the same network stack.

type NetworkRequest

type NetworkRequest struct {
	ContainerID string
	JoinTarget  NetworkJoinTarget
}

NetworkRequest describes a runtime-level network readiness request for a workspace container. Backend-specific details such as CNI configuration live inside the adapter.

type NetworkResult

type NetworkResult struct {
	IP string
}

NetworkResult captures the outcome of attaching the container to the default container network.

type NetworkService

type NetworkService interface {
	SetupNetwork(ctx context.Context, req NetworkRequest) (NetworkResult, error)
	RemoveNetwork(ctx context.Context, req NetworkRequest) error
	CheckNetwork(ctx context.Context, req NetworkRequest) error
}

NetworkService groups runtime network attachment operations.

type PrepareSnapshotRequest

type PrepareSnapshotRequest struct {
	Target StorageRef
	Parent SnapshotRef
}

type PullImageOptions

type PullImageOptions struct {
	Unpack        bool
	StorageDriver string
	OnProgress    func(PullProgress) // optional, nil = no progress reporting
}

type PullProgress

type PullProgress struct {
	Layers []LayerStatus `json:"layers"`
}

type ResourceLimits

type ResourceLimits struct {
	CPUMillicores int64
	MemoryBytes   int64
	StorageBytes  int64
}

ResourceLimits contains desired hard/soft workspace resource limits. A zero value for a field means unlimited.

type RuntimeInfo

type RuntimeInfo struct {
	Name string
}

type Service

Service is the workspace-facing container runtime abstraction.

type SnapshotInfo

type SnapshotInfo struct {
	Name    string
	Parent  string
	Kind    string
	Created time.Time
	Updated time.Time
	Labels  map[string]string
}

type SnapshotRef

type SnapshotRef struct {
	Driver string
	Key    string
	Kind   string
}

type SnapshotService

type SnapshotService interface {
	CommitSnapshot(ctx context.Context, req CommitSnapshotRequest) error
	ListSnapshots(ctx context.Context, req ListSnapshotsRequest) ([]SnapshotInfo, error)
	PrepareSnapshot(ctx context.Context, req PrepareSnapshotRequest) error
	RestoreContainer(ctx context.Context, req CreateContainerRequest) (ContainerInfo, error)
}

SnapshotService groups snapshot lifecycle operations.

type SnapshotUsage

type SnapshotUsage struct {
	SizeBytes uint64
	Inodes    uint64
}

type StartTaskOptions

type StartTaskOptions struct {
	Terminal bool
}

type StopTaskOptions

type StopTaskOptions struct {
	Signal  syscall.Signal
	Timeout time.Duration
	Force   bool
}

type StorageRef

type StorageRef struct {
	Driver string
	Key    string
	Kind   string
}

type TaskInfo

type TaskInfo struct {
	ContainerID       string
	ID                string
	PID               uint32
	NetworkJoinTarget NetworkJoinTarget
	Status            TaskStatus
	ExitCode          uint32
}

type TaskStatus

type TaskStatus int
const (
	TaskStatusUnknown TaskStatus = iota
	TaskStatusCreated
	TaskStatusRunning
	TaskStatusStopped
	TaskStatusPaused
)

func (TaskStatus) String

func (s TaskStatus) String() string

type WorkloadService

type WorkloadService interface {
	StartContainer(ctx context.Context, containerID string, opts *StartTaskOptions) error
	StopContainer(ctx context.Context, containerID string, opts *StopTaskOptions) error
	DeleteTask(ctx context.Context, containerID string, opts *DeleteTaskOptions) error
	GetTaskInfo(ctx context.Context, containerID string) (TaskInfo, error)
	GetContainerMetrics(ctx context.Context, containerID string) (ContainerMetrics, error)
	ListTasks(ctx context.Context, opts *ListTasksOptions) ([]TaskInfo, error)
}

WorkloadService groups primary workload lifecycle operations.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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