Documentation
¶
Index ¶
- func RuntimeStatusMessage(status RuntimeStatus, runtimeType Type) string
- type AttachOptions
- type BuildConfig
- type CommandExecutor
- type CreateConfig
- type DockerRuntime
- func (d *DockerRuntime) Attach(ctx context.Context, containerID string, opts *AttachOptions) error
- func (d *DockerRuntime) Build(ctx context.Context, config *BuildConfig) error
- func (d *DockerRuntime) Create(ctx context.Context, config *CreateConfig) (string, error)
- func (d *DockerRuntime) Exec(ctx context.Context, containerID string, cmd []string, opts *ExecOptions) error
- func (d *DockerRuntime) Info(ctx context.Context) (*RuntimeInfo, error)
- func (d *DockerRuntime) Inspect(ctx context.Context, containerID string) (*Info, error)
- func (d *DockerRuntime) List(ctx context.Context, filters map[string]string) ([]Info, error)
- func (d *DockerRuntime) Logs(ctx context.Context, containerID string, follow bool, tail string, ...) error
- func (d *DockerRuntime) Pull(ctx context.Context, image string) error
- func (d *DockerRuntime) Remove(ctx context.Context, containerID string, force bool) error
- func (d *DockerRuntime) Start(ctx context.Context, containerID string) error
- func (d *DockerRuntime) Stop(ctx context.Context, containerID string, timeout time.Duration) error
- type ExecOptions
- type Info
- type Mount
- type PodmanRuntime
- func (p *PodmanRuntime) Attach(ctx context.Context, containerID string, opts *AttachOptions) error
- func (p *PodmanRuntime) Build(ctx context.Context, config *BuildConfig) error
- func (p *PodmanRuntime) Create(ctx context.Context, config *CreateConfig) (string, error)
- func (p *PodmanRuntime) Exec(ctx context.Context, containerID string, cmd []string, opts *ExecOptions) error
- func (p *PodmanRuntime) Info(ctx context.Context) (*RuntimeInfo, error)
- func (p *PodmanRuntime) Inspect(ctx context.Context, containerID string) (*Info, error)
- func (p *PodmanRuntime) List(ctx context.Context, filters map[string]string) ([]Info, error)
- func (p *PodmanRuntime) Logs(ctx context.Context, containerID string, follow bool, tail string, ...) error
- func (p *PodmanRuntime) Pull(ctx context.Context, image string) error
- func (p *PodmanRuntime) Remove(ctx context.Context, containerID string, force bool) error
- func (p *PodmanRuntime) Start(ctx context.Context, containerID string) error
- func (p *PodmanRuntime) Stop(ctx context.Context, containerID string, timeout time.Duration) error
- type PortBinding
- type Runtime
- type RuntimeInfo
- type RuntimeStatus
- type Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RuntimeStatusMessage ¶
func RuntimeStatusMessage(status RuntimeStatus, runtimeType Type) string
RuntimeStatusMessage returns a user-friendly message describing the runtime status.
Types ¶
type AttachOptions ¶
type AttachOptions struct {
Shell string
ShellArgs []string
User string
// IO streams for input/output. If nil, defaults to os.Stdin and iolib.Data/UI.
Stdin io.Reader
Stdout io.Writer
Stderr io.Writer
}
AttachOptions represents options for attaching to containers.
type BuildConfig ¶
BuildConfig represents container image build configuration.
type CommandExecutor ¶
type CommandExecutor interface {
// LookPath searches for an executable named file in PATH.
LookPath(file string) (string, error)
// CommandContext creates an exec.Cmd configured to run with the given context.
CommandContext(ctx context.Context, name string, args ...string) *exec.Cmd
}
CommandExecutor provides an abstraction for executing system commands. This interface allows for mocking command execution in unit tests.
type CreateConfig ¶
type CreateConfig struct {
Name string
Image string
WorkspaceFolder string
Mounts []Mount
Ports []PortBinding
Env map[string]string
User string
Labels map[string]string
// Runtime configuration
RunArgs []string
OverrideCommand bool // Whether to override default command with sleep infinity
Init bool // Whether to use init process
Privileged bool // Run in privileged mode
CapAdd []string // Linux capabilities to add
SecurityOpt []string // Security options
}
CreateConfig represents container creation configuration.
type DockerRuntime ¶
type DockerRuntime struct{}
DockerRuntime implements the Runtime interface for Docker.
func NewDockerRuntime ¶
func NewDockerRuntime() *DockerRuntime
NewDockerRuntime creates a new Docker runtime.
func (*DockerRuntime) Attach ¶
func (d *DockerRuntime) Attach(ctx context.Context, containerID string, opts *AttachOptions) error
Attach attaches to a running container with an interactive shell.
func (*DockerRuntime) Build ¶
func (d *DockerRuntime) Build(ctx context.Context, config *BuildConfig) error
Build builds a container image from a Dockerfile.
func (*DockerRuntime) Create ¶
func (d *DockerRuntime) Create(ctx context.Context, config *CreateConfig) (string, error)
Create creates a new container.
func (*DockerRuntime) Exec ¶
func (d *DockerRuntime) Exec(ctx context.Context, containerID string, cmd []string, opts *ExecOptions) error
Exec executes a command in a running container.
func (*DockerRuntime) Info ¶
func (d *DockerRuntime) Info(ctx context.Context) (*RuntimeInfo, error)
Info gets runtime information.
func (*DockerRuntime) Logs ¶
func (d *DockerRuntime) Logs(ctx context.Context, containerID string, follow bool, tail string, stdout, stderr io.Writer) error
Logs shows logs from a container.
func (*DockerRuntime) Pull ¶
func (d *DockerRuntime) Pull(ctx context.Context, image string) error
Pull pulls a container image.
type ExecOptions ¶
type ExecOptions struct {
User string
WorkingDir string
Env []string
AttachStdin bool
AttachStdout bool
AttachStderr bool
Tty bool
// IO streams for input/output. If nil, defaults to iolib.Data/UI.
Stdin io.Reader
Stdout io.Writer
Stderr io.Writer
}
ExecOptions represents options for executing commands in containers.
type Info ¶
type Info struct {
ID string
Name string
Image string
Status string // running, stopped, exited, etc.
Created time.Time
Ports []PortBinding
Labels map[string]string
}
Info represents container state information.
type PodmanRuntime ¶
type PodmanRuntime struct{}
PodmanRuntime implements the Runtime interface for Podman.
func NewPodmanRuntime ¶
func NewPodmanRuntime() *PodmanRuntime
NewPodmanRuntime creates a new Podman runtime.
func (*PodmanRuntime) Attach ¶
func (p *PodmanRuntime) Attach(ctx context.Context, containerID string, opts *AttachOptions) error
Attach attaches to a running container with an interactive shell.
func (*PodmanRuntime) Build ¶
func (p *PodmanRuntime) Build(ctx context.Context, config *BuildConfig) error
Build builds a container image from a Dockerfile.
func (*PodmanRuntime) Create ¶
func (p *PodmanRuntime) Create(ctx context.Context, config *CreateConfig) (string, error)
Create creates a new container.
func (*PodmanRuntime) Exec ¶
func (p *PodmanRuntime) Exec(ctx context.Context, containerID string, cmd []string, opts *ExecOptions) error
Exec executes a command in a running container.
func (*PodmanRuntime) Info ¶
func (p *PodmanRuntime) Info(ctx context.Context) (*RuntimeInfo, error)
Info gets runtime information.
func (*PodmanRuntime) Logs ¶
func (p *PodmanRuntime) Logs(ctx context.Context, containerID string, follow bool, tail string, stdout, stderr io.Writer) error
Logs shows logs from a container.
func (*PodmanRuntime) Pull ¶
func (p *PodmanRuntime) Pull(ctx context.Context, image string) error
Pull pulls a container image.
type PortBinding ¶
PortBinding represents a port mapping.
type Runtime ¶
type Runtime interface {
// Lifecycle operations
Build(ctx context.Context, config *BuildConfig) error
Create(ctx context.Context, config *CreateConfig) (string, error)
Start(ctx context.Context, containerID string) error
Stop(ctx context.Context, containerID string, timeout time.Duration) error
Remove(ctx context.Context, containerID string, force bool) error
// State inspection
Inspect(ctx context.Context, containerID string) (*Info, error)
List(ctx context.Context, filters map[string]string) ([]Info, error)
// Execution - IO streams configured via options structs
Exec(ctx context.Context, containerID string, cmd []string, opts *ExecOptions) error
Attach(ctx context.Context, containerID string, opts *AttachOptions) error
// Image operations
Pull(ctx context.Context, image string) error
// Logs - methods that produce user-facing output accept io.Writer
Logs(ctx context.Context, containerID string, follow bool, tail string, stdout, stderr io.Writer) error
// Info
Info(ctx context.Context) (*RuntimeInfo, error)
}
Runtime defines the interface for container runtime operations. This interface abstracts Docker and Podman operations for testability.
func DetectRuntime ¶
DetectRuntime auto-detects the available container runtime. Priority order: 1. ATMOS_CONTAINER_RUNTIME environment variable 2. Docker (if available and running) 3. Podman (if available and running) Returns error if no runtime is available.
type RuntimeInfo ¶
RuntimeInfo represents container runtime information.
type RuntimeStatus ¶
type RuntimeStatus int
RuntimeStatus represents the availability status of a container runtime.
const ( // RuntimeAvailable indicates the runtime is available and responsive. RuntimeAvailable RuntimeStatus = iota RuntimeUnavailable // RuntimeNotResponding indicates the runtime binary exists but is not responding. RuntimeNotResponding // RuntimeNeedsInit indicates Podman is present but needs machine initialization. RuntimeNeedsInit // RuntimeNeedsStart indicates Podman machine exists but needs to be started. RuntimeNeedsStart )
func TryRecoverPodmanRuntime ¶
func TryRecoverPodmanRuntime(ctx context.Context) RuntimeStatus
TryRecoverPodmanRuntime attempts to recover Podman by initializing/starting the machine. This is an opt-in operation that should only be called when the user explicitly requests it. Returns the new status after recovery attempt.
type Type ¶
type Type string
Type represents the container runtime type.
func GetRuntimeType ¶
GetRuntimeType returns the type of a runtime instance.