Documentation
¶
Index ¶
- Constants
- func RunPullCommand(ctx context.Context, binary, image string, progress func(done, total int)) error
- type ContainerInfo
- type ContainerRuntime
- type DockerRuntime
- func (dr *DockerRuntime) CleanupNetwork(ctx context.Context) error
- func (dr *DockerRuntime) ContainerExists(containerIDOrName string) bool
- func (dr *DockerRuntime) EnsureNetwork(ctx context.Context) error
- func (dr *DockerRuntime) GetContainerHealth(ctx context.Context, containerIDOrName string) (HealthStatus, error)
- func (dr *DockerRuntime) GetNetworkName() string
- func (dr *DockerRuntime) ListRunningContainers(ctx context.Context, nameFilter string) ([]ContainerInfo, error)
- func (dr *DockerRuntime) PullImage(ctx context.Context, image string, progress func(done, total int)) error
- func (dr *DockerRuntime) RunContainer(ctx context.Context, opts RunContainerOptions) (string, error)
- func (dr *DockerRuntime) StopContainer(ctx context.Context, containerIDOrName string) error
- type HealthCheckConfig
- type HealthStatus
- type PodmanRuntime
- func (pr *PodmanRuntime) CleanupNetwork(ctx context.Context) error
- func (pr *PodmanRuntime) ContainerExists(containerIDOrName string) bool
- func (pr *PodmanRuntime) EnsureNetwork(ctx context.Context) error
- func (pr *PodmanRuntime) GetContainerHealth(ctx context.Context, containerIDOrName string) (HealthStatus, error)
- func (pr *PodmanRuntime) GetNetworkName() string
- func (pr *PodmanRuntime) ListRunningContainers(ctx context.Context, nameFilter string) ([]ContainerInfo, error)
- func (pr *PodmanRuntime) PullImage(ctx context.Context, image string, progress func(done, total int)) error
- func (pr *PodmanRuntime) RunContainer(ctx context.Context, opts RunContainerOptions) (string, error)
- func (pr *PodmanRuntime) StopContainer(ctx context.Context, containerIDOrName string) error
- type RunContainerOptions
- type RuntimeType
Constants ¶
const InferNetworkPrefix = "infer-network"
InferNetworkPrefix is the prefix for session-specific Docker networks
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ContainerInfo ¶
ContainerInfo represents basic container information
type ContainerRuntime ¶
type ContainerRuntime interface {
// Network operations
GetNetworkName() string
EnsureNetwork(ctx context.Context) error
CleanupNetwork(ctx context.Context) error
// Container lifecycle operations
ContainerExists(containerIDOrName string) bool
RunContainer(ctx context.Context, opts RunContainerOptions) (containerID string, err error)
StopContainer(ctx context.Context, containerIDOrName string) error
// Image operations. The optional progress callback receives layer counts
// as the pull advances.
PullImage(ctx context.Context, image string, progress func(done, total int)) error
// Container inspection
GetContainerHealth(ctx context.Context, containerIDOrName string) (HealthStatus, error)
ListRunningContainers(ctx context.Context, nameFilter string) ([]ContainerInfo, error)
}
ContainerRuntime defines the interface for container runtime operations This abstraction allows support for Docker, Podman, or any other container runtime
func NewContainerRuntime ¶
func NewContainerRuntime(sessionID convdomain.SessionID, runtimeType RuntimeType) (ContainerRuntime, error)
NewContainerRuntime creates a container runtime based on the configured type If runtimeType is empty, returns nil to allow binary mode fallback
func NewDockerRuntime ¶
func NewDockerRuntime(sessionID convdomain.SessionID) ContainerRuntime
NewDockerRuntime creates a new Docker runtime manager
func NewPodmanRuntime ¶
func NewPodmanRuntime(sessionID convdomain.SessionID) ContainerRuntime
NewPodmanRuntime creates a new Podman runtime manager
type DockerRuntime ¶
type DockerRuntime struct {
// contains filtered or unexported fields
}
DockerRuntime implements ContainerRuntime interface for Docker
func (*DockerRuntime) CleanupNetwork ¶
func (dr *DockerRuntime) CleanupNetwork(ctx context.Context) error
CleanupNetwork best-effort removes the shared network. Because the network is shared across sessions it may still be in use by another session's containers, in which case removal is refused and we leave it in place (keeping networkCreated set so a later call retries once the network frees up). It is never an error to fail here - shutdown must not block.
func (*DockerRuntime) ContainerExists ¶
func (dr *DockerRuntime) ContainerExists(containerIDOrName string) bool
ContainerExists checks if a Docker container exists by ID or name (running or stopped)
func (*DockerRuntime) EnsureNetwork ¶
func (dr *DockerRuntime) EnsureNetwork(ctx context.Context) error
EnsureNetwork creates the shared Docker network if it doesn't exist. The network is reused across sessions, so at most one ever exists. If creation fails because the IPAM address pools are exhausted (leaked networks from prior sessions), it prunes those and retries once.
func (*DockerRuntime) GetContainerHealth ¶
func (dr *DockerRuntime) GetContainerHealth(ctx context.Context, containerIDOrName string) (HealthStatus, error)
GetContainerHealth returns the health status of a container
func (*DockerRuntime) GetNetworkName ¶
func (dr *DockerRuntime) GetNetworkName() string
GetNetworkName returns the shared infer network name
func (*DockerRuntime) ListRunningContainers ¶
func (dr *DockerRuntime) ListRunningContainers(ctx context.Context, nameFilter string) ([]ContainerInfo, error)
ListRunningContainers lists all running containers matching the name filter
func (*DockerRuntime) PullImage ¶
func (dr *DockerRuntime) PullImage(ctx context.Context, image string, progress func(done, total int)) error
PullImage pulls a Docker image, reporting layer progress via the optional callback
func (*DockerRuntime) RunContainer ¶
func (dr *DockerRuntime) RunContainer(ctx context.Context, opts RunContainerOptions) (string, error)
RunContainer runs a Docker container with the given options
func (*DockerRuntime) StopContainer ¶
func (dr *DockerRuntime) StopContainer(ctx context.Context, containerIDOrName string) error
StopContainer stops a Docker container
type HealthCheckConfig ¶
type HealthCheckConfig struct {
Interval string // e.g., "10s"
Timeout string // e.g., "5s"
Retries int
StartPeriod string // e.g., "10s"
}
HealthCheckConfig defines container health check configuration
type HealthStatus ¶
type HealthStatus string
HealthStatus represents the health status of a container
const ( HealthStatusHealthy HealthStatus = "healthy" HealthStatusUnhealthy HealthStatus = "unhealthy" HealthStatusStarting HealthStatus = "starting" HealthStatusNone HealthStatus = "none" )
type PodmanRuntime ¶
type PodmanRuntime struct {
// contains filtered or unexported fields
}
PodmanRuntime implements ContainerRuntime interface for Podman
func (*PodmanRuntime) CleanupNetwork ¶
func (pr *PodmanRuntime) CleanupNetwork(ctx context.Context) error
CleanupNetwork best-effort removes the shared network. Because the network is shared across sessions it may still be in use by another session's containers, in which case removal is refused and we leave it in place (keeping networkCreated set so a later call retries once the network frees up). It is never an error to fail here - shutdown must not block.
func (*PodmanRuntime) ContainerExists ¶
func (pr *PodmanRuntime) ContainerExists(containerIDOrName string) bool
ContainerExists checks if a Podman container exists by ID or name (running or stopped)
func (*PodmanRuntime) EnsureNetwork ¶
func (pr *PodmanRuntime) EnsureNetwork(ctx context.Context) error
EnsureNetwork creates the shared Podman network if it doesn't exist. The network is reused across sessions, so at most one ever exists. If creation fails because the IPAM address pools are exhausted (leaked networks from prior sessions), it prunes those and retries once.
func (*PodmanRuntime) GetContainerHealth ¶
func (pr *PodmanRuntime) GetContainerHealth(ctx context.Context, containerIDOrName string) (HealthStatus, error)
GetContainerHealth returns the health status of a container
func (*PodmanRuntime) GetNetworkName ¶
func (pr *PodmanRuntime) GetNetworkName() string
GetNetworkName returns the shared infer network name
func (*PodmanRuntime) ListRunningContainers ¶
func (pr *PodmanRuntime) ListRunningContainers(ctx context.Context, nameFilter string) ([]ContainerInfo, error)
ListRunningContainers lists all running containers matching the name filter
func (*PodmanRuntime) PullImage ¶
func (pr *PodmanRuntime) PullImage(ctx context.Context, image string, progress func(done, total int)) error
PullImage pulls a Podman image, reporting layer progress via the optional callback
func (*PodmanRuntime) RunContainer ¶
func (pr *PodmanRuntime) RunContainer(ctx context.Context, opts RunContainerOptions) (string, error)
RunContainer runs a Podman container with the given options
func (*PodmanRuntime) StopContainer ¶
func (pr *PodmanRuntime) StopContainer(ctx context.Context, containerIDOrName string) error
StopContainer stops a Podman container
type RunContainerOptions ¶
type RunContainerOptions struct {
Name string
Image string
Network string
Ports []string // Format: "host:container" or "host:container/protocol"
Environment map[string]string
Volumes []string // Format: "host:container" or "host:container:mode"
Entrypoint []string
Command []string
Args []string
HealthCmd string
HealthConfig *HealthCheckConfig
RemoveOnExit bool
Detached bool
EnvFile string // Optional .env file path
}
RunContainerOptions contains all options for running a container
type RuntimeType ¶
type RuntimeType string
RuntimeType represents the type of container runtime
const ( RuntimeTypeDocker RuntimeType = "docker" RuntimeTypePodman RuntimeType = "podman" )