Documentation
¶
Index ¶
- Constants
- Variables
- func MountSnapshot(ctx context.Context, service Service, snapshotter, key string) (string, func() error, error)
- func ResolveConfSource(dataDir string) (string, error)
- type AppleService
- func (s *AppleService) Close() error
- func (s *AppleService) CommitSnapshot(context.Context, string, string, string) error
- func (s *AppleService) CreateContainer(ctx context.Context, req CreateContainerRequest) (ContainerInfo, error)
- func (s *AppleService) CreateContainerFromSnapshot(context.Context, CreateContainerRequest) (ContainerInfo, error)
- func (s *AppleService) DeleteContainer(ctx context.Context, id string, opts *DeleteContainerOptions) error
- func (s *AppleService) DeleteImage(ctx context.Context, ref string, opts *DeleteImageOptions) error
- func (s *AppleService) DeleteTask(context.Context, string, *DeleteTaskOptions) error
- func (s *AppleService) ExecTask(ctx context.Context, containerID string, req ExecTaskRequest) (ExecTaskResult, error)
- func (s *AppleService) ExecTaskStreaming(context.Context, string, ExecTaskRequest) (*ExecTaskSession, error)
- func (s *AppleService) GetContainer(ctx context.Context, id string) (ContainerInfo, error)
- func (s *AppleService) GetImage(ctx context.Context, ref string) (ImageInfo, error)
- func (s *AppleService) GetTaskInfo(ctx context.Context, containerID string) (TaskInfo, error)
- func (s *AppleService) ListContainers(ctx context.Context) ([]ContainerInfo, error)
- func (s *AppleService) ListContainersByLabel(ctx context.Context, key, value string) ([]ContainerInfo, error)
- func (s *AppleService) ListImages(ctx context.Context) ([]ImageInfo, error)
- func (s *AppleService) ListSnapshots(context.Context, string) ([]SnapshotInfo, error)
- func (s *AppleService) ListTasks(ctx context.Context, opts *ListTasksOptions) ([]TaskInfo, error)
- func (s *AppleService) PrepareSnapshot(context.Context, string, string, string) error
- func (s *AppleService) PullImage(ctx context.Context, ref string, opts *PullImageOptions) (ImageInfo, error)
- func (s *AppleService) RemoveNetwork(context.Context, NetworkSetupRequest) error
- func (s *AppleService) SetupNetwork(context.Context, NetworkSetupRequest) error
- func (s *AppleService) SnapshotMounts(context.Context, string, string) ([]MountInfo, error)
- func (s *AppleService) StartContainer(ctx context.Context, containerID string, opts *StartTaskOptions) error
- func (s *AppleService) StopContainer(ctx context.Context, containerID string, opts *StopTaskOptions) error
- type AppleServiceConfig
- type ClientFactory
- type ContainerInfo
- type ContainerSpec
- type CreateContainerRequest
- type DefaultClientFactory
- type DefaultService
- func (s *DefaultService) CommitSnapshot(ctx context.Context, snapshotter, name, key string) error
- func (s *DefaultService) CreateContainer(ctx context.Context, req CreateContainerRequest) (ContainerInfo, error)
- func (s *DefaultService) CreateContainerFromSnapshot(ctx context.Context, req CreateContainerRequest) (ContainerInfo, error)
- func (s *DefaultService) DeleteContainer(ctx context.Context, id string, opts *DeleteContainerOptions) error
- func (s *DefaultService) DeleteImage(ctx context.Context, ref string, opts *DeleteImageOptions) error
- func (s *DefaultService) DeleteTask(ctx context.Context, containerID string, opts *DeleteTaskOptions) error
- func (s *DefaultService) ExecTask(ctx context.Context, containerID string, req ExecTaskRequest) (ExecTaskResult, error)
- func (s *DefaultService) ExecTaskStreaming(ctx context.Context, containerID string, req ExecTaskRequest) (*ExecTaskSession, error)
- func (s *DefaultService) GetContainer(ctx context.Context, id string) (ContainerInfo, error)
- func (s *DefaultService) GetImage(ctx context.Context, ref string) (ImageInfo, error)
- func (s *DefaultService) GetTaskInfo(ctx context.Context, containerID string) (TaskInfo, error)
- func (s *DefaultService) ListContainers(ctx context.Context) ([]ContainerInfo, error)
- func (s *DefaultService) ListContainersByLabel(ctx context.Context, key, value string) ([]ContainerInfo, error)
- func (s *DefaultService) ListImages(ctx context.Context) ([]ImageInfo, error)
- func (s *DefaultService) ListSnapshots(ctx context.Context, snapshotter string) ([]SnapshotInfo, error)
- func (s *DefaultService) ListTasks(ctx context.Context, opts *ListTasksOptions) ([]TaskInfo, error)
- func (s *DefaultService) PrepareSnapshot(ctx context.Context, snapshotter, key, parent string) error
- func (s *DefaultService) PullImage(ctx context.Context, ref string, opts *PullImageOptions) (ImageInfo, error)
- func (s *DefaultService) RemoveNetwork(ctx context.Context, req NetworkSetupRequest) error
- func (s *DefaultService) SetupNetwork(ctx context.Context, req NetworkSetupRequest) error
- func (s *DefaultService) SnapshotMounts(ctx context.Context, snapshotter, key string) ([]MountInfo, error)
- func (s *DefaultService) StartContainer(ctx context.Context, containerID string, opts *StartTaskOptions) error
- func (s *DefaultService) StopContainer(ctx context.Context, containerID string, opts *StopTaskOptions) error
- type DeleteContainerOptions
- type DeleteImageOptions
- type DeleteTaskOptions
- type ExecTaskRequest
- type ExecTaskResult
- type ExecTaskSession
- type ImageInfo
- type ListTasksOptions
- type MountInfo
- type MountSpec
- type MountedSnapshot
- type NetworkSetupRequest
- type PullImageOptions
- type RuntimeInfo
- type Service
- type SnapshotCommitResult
- type SnapshotInfo
- type StartTaskOptions
- type StopTaskOptions
- type TaskInfo
- type TaskStatus
Constants ¶
View Source
const ( DefaultSocketPath = "/run/containerd/containerd.sock" DefaultNamespace = "default" BackendContainerd = "containerd" BackendApple = "apple" )
Variables ¶
View Source
var ( ErrInvalidArgument = errors.New("invalid argument") ErrTaskStopTimeout = errors.New("timeout waiting for task to stop") )
View Source
var ErrNotSupported = errors.New("operation not supported on this backend")
Functions ¶
func MountSnapshot ¶
func MountSnapshot(ctx context.Context, service Service, snapshotter, key string) (string, func() error, error)
MountSnapshot mounts a snapshot by snapshotter/key without a container.
func ResolveConfSource ¶
ResolveConfSource returns a host path to mount as /etc/resolv.conf. If systemd-resolved config is available, use it. Otherwise write a fallback resolv.conf under dataDir and return that path.
Types ¶
type AppleService ¶
type AppleService struct {
// contains filtered or unexported fields
}
func NewAppleService ¶
func NewAppleService(ctx context.Context, log *slog.Logger, cfg AppleServiceConfig) (*AppleService, error)
func (*AppleService) Close ¶
func (s *AppleService) Close() error
func (*AppleService) CommitSnapshot ¶
func (*AppleService) CreateContainer ¶
func (s *AppleService) CreateContainer(ctx context.Context, req CreateContainerRequest) (ContainerInfo, error)
func (*AppleService) CreateContainerFromSnapshot ¶
func (s *AppleService) CreateContainerFromSnapshot(context.Context, CreateContainerRequest) (ContainerInfo, error)
func (*AppleService) DeleteContainer ¶
func (s *AppleService) DeleteContainer(ctx context.Context, id string, opts *DeleteContainerOptions) error
func (*AppleService) DeleteImage ¶
func (s *AppleService) DeleteImage(ctx context.Context, ref string, opts *DeleteImageOptions) error
func (*AppleService) DeleteTask ¶
func (s *AppleService) DeleteTask(context.Context, string, *DeleteTaskOptions) error
func (*AppleService) ExecTask ¶
func (s *AppleService) ExecTask(ctx context.Context, containerID string, req ExecTaskRequest) (ExecTaskResult, error)
ExecTask executes a command inside the container.
Limitations compared to the containerd backend:
- WorkDir: the Apple Container exec API (ExecCreateRequest) has no working-directory field; req.WorkDir is silently ignored.
- Env: similarly, environment variables cannot be injected at exec time via this API; req.Env is silently ignored.
- Stdin: the acgo exec interface does not expose a write channel, so req.Stdin is not connected and the process receives no stdin input.
- Stderr: the Apple Container API returns stdout and stderr as a single combined stream; they cannot be routed to separate writers. The combined output is sent to req.Stdout when set, otherwise to req.Stderr when set, otherwise discarded.
- FIFODir: a containerd-specific concept; not applicable here.
func (*AppleService) ExecTaskStreaming ¶
func (s *AppleService) ExecTaskStreaming(context.Context, string, ExecTaskRequest) (*ExecTaskSession, error)
func (*AppleService) GetContainer ¶
func (s *AppleService) GetContainer(ctx context.Context, id string) (ContainerInfo, error)
func (*AppleService) GetTaskInfo ¶
func (*AppleService) ListContainers ¶
func (s *AppleService) ListContainers(ctx context.Context) ([]ContainerInfo, error)
func (*AppleService) ListContainersByLabel ¶
func (s *AppleService) ListContainersByLabel(ctx context.Context, key, value string) ([]ContainerInfo, error)
func (*AppleService) ListImages ¶
func (s *AppleService) ListImages(ctx context.Context) ([]ImageInfo, error)
func (*AppleService) ListSnapshots ¶
func (s *AppleService) ListSnapshots(context.Context, string) ([]SnapshotInfo, error)
func (*AppleService) ListTasks ¶
func (s *AppleService) ListTasks(ctx context.Context, opts *ListTasksOptions) ([]TaskInfo, error)
func (*AppleService) PrepareSnapshot ¶
func (*AppleService) PullImage ¶
func (s *AppleService) PullImage(ctx context.Context, ref string, opts *PullImageOptions) (ImageInfo, error)
func (*AppleService) RemoveNetwork ¶
func (s *AppleService) RemoveNetwork(context.Context, NetworkSetupRequest) error
func (*AppleService) SetupNetwork ¶
func (s *AppleService) SetupNetwork(context.Context, NetworkSetupRequest) error
func (*AppleService) SnapshotMounts ¶
func (*AppleService) StartContainer ¶
func (s *AppleService) StartContainer(ctx context.Context, containerID string, opts *StartTaskOptions) error
func (*AppleService) StopContainer ¶
func (s *AppleService) StopContainer(ctx context.Context, containerID string, opts *StopTaskOptions) error
type AppleServiceConfig ¶
type ClientFactory ¶
type ClientFactory interface {
New(ctx context.Context) (*containerd.Client, error)
}
type ContainerInfo ¶
type ContainerSpec ¶
type CreateContainerRequest ¶
type DefaultClientFactory ¶
type DefaultClientFactory struct {
SocketPath string
}
func (DefaultClientFactory) New ¶
func (f DefaultClientFactory) New(_ context.Context) (*containerd.Client, error)
type DefaultService ¶
type DefaultService struct {
// contains filtered or unexported fields
}
func NewDefaultService ¶
func NewDefaultService(log *slog.Logger, client *containerd.Client, cfg config.Config) *DefaultService
func (*DefaultService) CommitSnapshot ¶
func (s *DefaultService) CommitSnapshot(ctx context.Context, snapshotter, name, key string) error
func (*DefaultService) CreateContainer ¶
func (s *DefaultService) CreateContainer(ctx context.Context, req CreateContainerRequest) (ContainerInfo, error)
func (*DefaultService) CreateContainerFromSnapshot ¶
func (s *DefaultService) CreateContainerFromSnapshot(ctx context.Context, req CreateContainerRequest) (ContainerInfo, error)
func (*DefaultService) DeleteContainer ¶
func (s *DefaultService) DeleteContainer(ctx context.Context, id string, opts *DeleteContainerOptions) error
func (*DefaultService) DeleteImage ¶
func (s *DefaultService) DeleteImage(ctx context.Context, ref string, opts *DeleteImageOptions) error
func (*DefaultService) DeleteTask ¶
func (s *DefaultService) DeleteTask(ctx context.Context, containerID string, opts *DeleteTaskOptions) error
func (*DefaultService) ExecTask ¶
func (s *DefaultService) ExecTask(ctx context.Context, containerID string, req ExecTaskRequest) (ExecTaskResult, error)
func (*DefaultService) ExecTaskStreaming ¶
func (s *DefaultService) ExecTaskStreaming(ctx context.Context, containerID string, req ExecTaskRequest) (*ExecTaskSession, error)
func (*DefaultService) GetContainer ¶
func (s *DefaultService) GetContainer(ctx context.Context, id string) (ContainerInfo, error)
func (*DefaultService) GetTaskInfo ¶
func (*DefaultService) ListContainers ¶
func (s *DefaultService) ListContainers(ctx context.Context) ([]ContainerInfo, error)
func (*DefaultService) ListContainersByLabel ¶
func (s *DefaultService) ListContainersByLabel(ctx context.Context, key, value string) ([]ContainerInfo, error)
func (*DefaultService) ListImages ¶
func (s *DefaultService) ListImages(ctx context.Context) ([]ImageInfo, error)
func (*DefaultService) ListSnapshots ¶
func (s *DefaultService) ListSnapshots(ctx context.Context, snapshotter string) ([]SnapshotInfo, error)
func (*DefaultService) ListTasks ¶
func (s *DefaultService) ListTasks(ctx context.Context, opts *ListTasksOptions) ([]TaskInfo, error)
func (*DefaultService) PrepareSnapshot ¶
func (s *DefaultService) PrepareSnapshot(ctx context.Context, snapshotter, key, parent string) error
func (*DefaultService) PullImage ¶
func (s *DefaultService) PullImage(ctx context.Context, ref string, opts *PullImageOptions) (ImageInfo, error)
func (*DefaultService) RemoveNetwork ¶
func (s *DefaultService) RemoveNetwork(ctx context.Context, req NetworkSetupRequest) error
func (*DefaultService) SetupNetwork ¶
func (s *DefaultService) SetupNetwork(ctx context.Context, req NetworkSetupRequest) error
func (*DefaultService) SnapshotMounts ¶
func (*DefaultService) StartContainer ¶
func (s *DefaultService) StartContainer(ctx context.Context, containerID string, opts *StartTaskOptions) error
func (*DefaultService) StopContainer ¶
func (s *DefaultService) StopContainer(ctx context.Context, containerID string, opts *StopTaskOptions) error
type DeleteContainerOptions ¶
type DeleteContainerOptions struct {
CleanupSnapshot bool
}
type DeleteImageOptions ¶
type DeleteImageOptions struct {
Synchronous bool
}
type DeleteTaskOptions ¶
type DeleteTaskOptions struct {
Force bool
}
type ExecTaskRequest ¶
type ExecTaskResult ¶
type ExecTaskResult struct {
ExitCode uint32
}
type ExecTaskSession ¶
type ExecTaskSession struct {
Stdin io.WriteCloser
Stdout io.ReadCloser
Stderr io.ReadCloser
Wait func() (ExecTaskResult, error)
Close func() error
}
type ListTasksOptions ¶
type ListTasksOptions struct {
Filter string
}
type MountSpec ¶
func TimezoneSpec ¶
TimezoneSpec returns mount specs and environment variables that propagate the host timezone into the container via /etc/localtime bind-mount and TZ environment variable.
type MountedSnapshot ¶
type MountedSnapshot struct {
Dir string
Info ContainerInfo
Unmount func() error
}
func MountContainerSnapshot ¶
func MountContainerSnapshot(ctx context.Context, service Service, containerID string) (*MountedSnapshot, error)
MountContainerSnapshot mounts the active snapshot for a container.
type NetworkSetupRequest ¶
type PullImageOptions ¶
type RuntimeInfo ¶
type RuntimeInfo struct {
Name string
}
type Service ¶
type Service 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
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)
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)
ListTasks(ctx context.Context, opts *ListTasksOptions) ([]TaskInfo, error)
ExecTask(ctx context.Context, containerID string, req ExecTaskRequest) (ExecTaskResult, error)
ExecTaskStreaming(ctx context.Context, containerID string, req ExecTaskRequest) (*ExecTaskSession, error)
SetupNetwork(ctx context.Context, req NetworkSetupRequest) error
RemoveNetwork(ctx context.Context, req NetworkSetupRequest) error
CommitSnapshot(ctx context.Context, snapshotter, name, key string) error
ListSnapshots(ctx context.Context, snapshotter string) ([]SnapshotInfo, error)
PrepareSnapshot(ctx context.Context, snapshotter, key, parent string) error
CreateContainerFromSnapshot(ctx context.Context, req CreateContainerRequest) (ContainerInfo, error)
SnapshotMounts(ctx context.Context, snapshotter, key string) ([]MountInfo, error)
}
type SnapshotCommitResult ¶
type SnapshotInfo ¶
type StartTaskOptions ¶
type StopTaskOptions ¶
type TaskInfo ¶
type TaskInfo struct {
ContainerID string
ID string
PID uint32
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
Click to show internal directories.
Click to hide internal directories.