Files
yms-daemon/internal/containerengine/engine.go
T

88 lines
2.3 KiB
Go
Raw Normal View History

2026-08-15 20:58:01 +08:00
// Package containerengine defines the container runtime boundary used by update executors.
package containerengine
import (
"context"
"errors"
"io"
)
var ErrNotFound = errors.New("container engine object not found")
// Platform is an explicit OCI operating system and CPU platform.
type Platform struct {
OS string
Architecture string
Variant string
}
// Image is the immutable image information returned by the engine.
type Image struct {
ID string
RepoDigests []string
DescriptorDigest string
Platform Platform
}
// RestartPolicy is passed to the engine without an implicit default.
type RestartPolicy struct {
Name string
MaximumRetryCount int
}
// Mount is one explicit container mount.
type Mount struct {
Type string
Source string
Target string
ReadOnly bool
}
// ContainerSpec contains every property controlled by the backend executor.
type ContainerSpec struct {
2026-08-16 17:12:06 +08:00
Name string
ImageReference string
Platform Platform
Environment []string
Labels map[string]string
NetworkMode string
RestartPolicy RestartPolicy
Mounts []Mount
User string
StopTimeoutSeconds int
2026-08-15 20:58:01 +08:00
}
// Container is the runtime state required for idempotent inspection.
type Container struct {
2026-08-16 17:12:06 +08:00
ID string
Name string
ImageID string
ImageReference string
Platform string
Running bool
Dead bool
Status string
Environment []string
Labels map[string]string
NetworkMode string
RestartPolicy RestartPolicy
Mounts []Mount
User string
StopTimeoutSeconds int
2026-08-15 20:58:01 +08:00
}
// Engine is the smallest container runtime API required by an update executor.
type Engine interface {
Ping(context.Context) error
2026-08-16 17:12:06 +08:00
PullImage(context.Context, string) error
2026-08-15 20:58:01 +08:00
LoadImage(context.Context, io.Reader) error
InspectImage(context.Context, string) (Image, error)
CreateContainer(context.Context, ContainerSpec) (Container, error)
StartContainer(context.Context, string) error
2026-08-17 02:10:10 +08:00
ContainerLogs(context.Context, string) (io.ReadCloser, error)
2026-08-16 17:12:06 +08:00
StopContainer(context.Context, string) error
2026-08-15 20:58:01 +08:00
InspectContainer(context.Context, string) (Container, error)
RemoveContainer(context.Context, string, bool) error
Close() error
}