Documentation
¶
Index ¶
- Constants
- func BuildEphemeralPreview(runtimeName string, config *EphemeralConfig) string
- func BuildImageBuildPreview(runtimeName string, config *BuildConfig) string
- func BuildImagePushPreview(runtimeName, image string) string
- func BuildImageTagPreview(runtimeName, source, target string) string
- func DiscoveryFilter(stack, componentType, component string) map[string]string
- func Down(ctx context.Context, runtime Runtime, stack, componentType, component string) error
- func ExitCode(err error) int
- func HostRuntimeSocket(ctx context.Context, runtime Runtime) (string, error)
- func InstanceAddress(stack, componentType, component string) string
- func InstanceLabels(stack, componentType, component string) map[string]string
- func IsContainerRunning(status string) bool
- func IsImageMissingError(err error) bool
- func RenderImageSummaryMarkdown(info *ImageInfo, opts ImageSummaryOptions) string
- func RuntimeIsRootless(ctx context.Context, runtime Runtime) bool
- func RuntimeName(stack, componentType, component string) string
- func RuntimeStatusMessage(status RuntimeStatus, runtimeType Type) string
- func ValidateRunStep(step *schema.ContainerRunStep) error
- func WaitHealthy(ctx context.Context, runtime Runtime, inst Instance, timeout time.Duration) error
- type AttachOptions
- type BakeConfig
- type BuildConfig
- 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) EnsureNetwork(ctx context.Context, name string) error
- func (d *DockerRuntime) Exec(ctx context.Context, containerID string, cmd []string, opts *ExecOptions) error
- func (d *DockerRuntime) ImageInspect(ctx context.Context, image string) (*ImageInfo, 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) Push(ctx context.Context, image string) (*PushResult, error)
- func (d *DockerRuntime) Remove(ctx context.Context, containerID string, force bool) error
- func (d *DockerRuntime) SetEnv(env []string)
- func (d *DockerRuntime) Shell(ctx context.Context, containerID string, opts *ShellOptions) error
- func (d *DockerRuntime) Start(ctx context.Context, containerID string) error
- func (d *DockerRuntime) Stop(ctx context.Context, containerID string, timeout time.Duration) error
- func (d *DockerRuntime) Tag(ctx context.Context, source, target string) error
- type EnvSetter
- type EphemeralConfig
- type EphemeralResult
- type ExecOptions
- type HealthCheck
- type ImageInfo
- type ImageSummaryOptions
- type Info
- type Instance
- type Mount
- type Named
- type NamedConfig
- type NetworkAttachment
- type NetworkEnsurer
- 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) EnsureNetwork(ctx context.Context, name string) error
- func (p *PodmanRuntime) Exec(ctx context.Context, containerID string, cmd []string, opts *ExecOptions) error
- func (p *PodmanRuntime) ImageInspect(ctx context.Context, image string) (*ImageInfo, 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) Push(ctx context.Context, image string) (*PushResult, error)
- func (p *PodmanRuntime) Remove(ctx context.Context, containerID string, force bool) error
- func (p *PodmanRuntime) SetEnv(env []string)
- func (p *PodmanRuntime) Shell(ctx context.Context, containerID string, opts *ShellOptions) error
- func (p *PodmanRuntime) Start(ctx context.Context, containerID string) error
- func (p *PodmanRuntime) Stop(ctx context.Context, containerID string, timeout time.Duration) error
- func (p *PodmanRuntime) Tag(ctx context.Context, source, target string) error
- type PortBinding
- type PushResult
- type RestartPolicy
- type Runtime
- type RuntimeInfo
- type RuntimeStatus
- type Sandbox
- type SandboxConfig
- type ShellOptions
- type Type
Constants ¶
const ( // PullMissing pulls only after initial container creation fails. PullMissing = "missing" // PullAlways pulls the image before creating the container. PullAlways = "always" // PullNever never pulls the image. PullNever = "never" // CleanupAlways removes the container after execution, even on failure. CleanupAlways = "always" // CleanupOnSuccess removes the container only after successful execution. CleanupOnSuccess = "on_success" // CleanupNever leaves the container behind. CleanupNever = "never" )
const ( // LabelStack records the stack of the component instance. LabelStack = "tools.atmos.stack" // LabelComponentType records the component kind (e.g. "container"). LabelComponentType = "tools.atmos.component_type" // LabelComponent records the component name. LabelComponent = "tools.atmos.component" // LabelInstance records the full canonical instance address. LabelInstance = "tools.atmos.instance" )
Canonical runtime labels for Atmos-managed container component instances. These derive from the component instance address (<stack>/<component_type>/<component>) and are used for label-based discovery instead of local state files.
const ( SandboxLabelType = "tools.atmos.type" SandboxLabelWorkflow = "tools.atmos.workflow" SandboxLabelWorkflowPath = "tools.atmos.workflow.path" SandboxLabelRunID = "tools.atmos.run.id" SandboxLabelWorkspace = "tools.atmos.workspace" SandboxTypeWorkflow = "workflow-sandbox" )
const ( // DefaultHealthyTimeout bounds how long WaitHealthy waits for a container to // report a healthy state before giving up. DefaultHealthyTimeout = 90 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func BuildEphemeralPreview ¶ added in v1.222.0
func BuildEphemeralPreview(runtimeName string, config *EphemeralConfig) string
BuildEphemeralPreview builds a human-readable equivalent runtime command.
func BuildImageBuildPreview ¶ added in v1.222.0
func BuildImageBuildPreview(runtimeName string, config *BuildConfig) string
BuildImageBuildPreview builds a human-readable equivalent image build command.
func BuildImagePushPreview ¶ added in v1.222.0
BuildImagePushPreview builds a human-readable equivalent image push command.
func BuildImageTagPreview ¶ added in v1.222.0
BuildImageTagPreview builds a human-readable equivalent image tag command.
func DiscoveryFilter ¶ added in v1.222.0
DiscoveryFilter returns the runtime List() filter that matches a specific instance by its canonical instance label.
func Down ¶ added in v1.222.0
Down stops and removes the long-lived container for a component instance, discovered by label. It is a no-op (nil error) when no instance is found.
func HostRuntimeSocket ¶ added in v1.222.0
HostRuntimeSocket returns the host container runtime socket path for the active runtime, used to grant a container access to that runtime (Docker-out-of-Docker).
func InstanceAddress ¶ added in v1.222.0
InstanceAddress builds the canonical component instance address "<stack>/<component_type>/<component>" (e.g. "dev/container/api").
func InstanceLabels ¶ added in v1.222.0
InstanceLabels builds the canonical label map used both to create and to discover an Atmos-managed container component instance.
func IsContainerRunning ¶ added in v1.222.0
IsContainerRunning reports whether a runtime status string indicates a running container. It accepts both Docker's "running"/"Up ..." forms.
func IsImageMissingError ¶ added in v1.222.0
IsImageMissingError reports whether an error indicates the image is not present locally (and is therefore recoverable by pulling or building), as opposed to an unrelated failure (transport, auth, daemon) that neither fixes.
func RenderImageSummaryMarkdown ¶ added in v1.223.0
func RenderImageSummaryMarkdown(info *ImageInfo, opts ImageSummaryOptions) string
RenderImageSummaryMarkdown renders a GitHub-flavored Markdown job summary for a container image. The format intentionally mirrors the summary produced by Cloud Posse's Docker build action so native Atmos container builds have the same CI polish without an extra GitHub Action.
func RuntimeIsRootless ¶ added in v1.222.0
RuntimeIsRootless reports whether the given runtime runs containers rootlessly (in a user namespace). Rootless runtimes — notably the default macOS Podman machine — don't delegate every cgroup-v2 controller to containers and run them in a user namespace, which some workloads (e.g. k3s) must accommodate.
It is best-effort: on any detection failure it returns false (assume rootful), so the default behavior is always the rootful path.
func RuntimeName ¶ added in v1.222.0
RuntimeName builds the sanitized runtime container name for an instance, projecting the canonical address onto a name safe for Docker/Podman (e.g. "atmos-dev-container-api").
func RuntimeStatusMessage ¶
func RuntimeStatusMessage(status RuntimeStatus, runtimeType Type) string
RuntimeStatusMessage returns a user-friendly message describing the runtime status.
func ValidateRunStep ¶ added in v1.222.0
func ValidateRunStep(step *schema.ContainerRunStep) error
ValidateRunStep checks a run step's restart/healthcheck settings up front so a misconfiguration surfaces as a friendly Atmos error instead of an opaque docker/podman failure at create time. It is a no-op when step is nil.
func WaitHealthy ¶ added in v1.222.0
WaitHealthy blocks until the long-lived container for a component instance reports a healthy state, or the timeout elapses. It is meant for containers created with a health check: a container with no health check never reports a health state, so callers must only invoke this when a health check is configured (otherwise it would always time out). An "unhealthy" state — which the runtime reports only after the start period and the configured retries — fails fast rather than waiting out the timeout.
Types ¶
type AttachOptions ¶
type AttachOptions struct {
// NoStdin attaches output only, leaving the container's stdin unconnected
// (maps to `--no-stdin`).
NoStdin bool
// DetachKeys overrides the key sequence that detaches without stopping the
// container (maps to `--detach-keys`; runtime default is ctrl-p,ctrl-q).
DetachKeys 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 a container's main process (PID 1) via `docker/podman attach`.
type BakeConfig ¶ added in v1.222.0
type BakeConfig struct {
File string
Files []string
Target string
Targets []string
Set []string
Vars map[string]string
Load bool
Push bool
Print bool
}
BakeConfig represents Docker Buildx Bake configuration.
type BuildConfig ¶
type BuildConfig struct {
Dockerfile string
Context string
Engine string
Args map[string]string
Tags []string
Target string
NoCache bool
Pull bool
Bake *BakeConfig
}
BuildConfig represents container image build configuration.
type CreateConfig ¶
type CreateConfig struct {
Name string
Image string
Command []string // Command/args to run; appended after the image. Ignored when OverrideCommand is set.
WorkspaceFolder string
Mounts []Mount
Ports []PortBinding
Networks []NetworkAttachment
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
Host bool // Grant access to the host container runtime (Docker-out-of-Docker)
CapAdd []string // Linux capabilities to add
SecurityOpt []string // Security options
Restart *RestartPolicy // Restart policy (nil = runtime default)
HealthCheck *HealthCheck // Health check (nil = inherit image healthcheck)
}
CreateConfig represents container creation configuration.
type DockerRuntime ¶
type DockerRuntime struct {
// contains filtered or unexported fields
}
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 connects to a running container's main process (PID 1) via `docker attach`.
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) EnsureNetwork ¶ added in v1.222.0
func (d *DockerRuntime) EnsureNetwork(ctx context.Context, name string) error
EnsureNetwork idempotently creates a user-defined docker network. It implements NetworkEnsurer so emulators in a stack can share a network and resolve each other by component name.
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) ImageInspect ¶ added in v1.222.0
ImageInspect returns metadata for a local container image.
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.
func (*DockerRuntime) Push ¶ added in v1.222.0
func (d *DockerRuntime) Push(ctx context.Context, image string) (*PushResult, error)
Push pushes a container image.
func (*DockerRuntime) SetEnv ¶ added in v1.222.0
func (d *DockerRuntime) SetEnv(env []string)
SetEnv sets the environment for docker CLI subprocesses launched by this runtime. See EnvSetter for the rationale.
func (*DockerRuntime) Shell ¶ added in v1.222.0
func (d *DockerRuntime) Shell(ctx context.Context, containerID string, opts *ShellOptions) error
Shell opens an interactive shell in a running container (a new shell process via `exec`).
func (*DockerRuntime) Start ¶
func (d *DockerRuntime) Start(ctx context.Context, containerID string) error
Start starts a container.
type EnvSetter ¶ added in v1.222.0
type EnvSetter interface {
SetEnv(env []string)
}
EnvSetter is implemented by runtimes whose CLI subprocesses can be launched with a specific environment. The container step uses this to forward the identity-resolved environment (e.g. the DOCKER_CONFIG materialized by the aws/ecr auth integration, or AWS_* credentials) so build/push/run can reach private registries. Runtimes that do not implement it inherit os.Environ().
type EphemeralConfig ¶ added in v1.222.0
type EphemeralConfig struct {
Name string
Image string
Command []string
WorkspaceHostPath string
WorkspaceFolder string
WorkspaceReadOnly bool
Mounts []Mount
Ports []PortBinding
Env []string
User string
Labels map[string]string
RunArgs []string
PullPolicy string
CleanupPolicy string
TTY bool
Interactive bool
Stdin io.Reader
Host bool // grant access to the host container runtime (Docker-out-of-Docker)
}
EphemeralConfig describes a one-shot container execution.
type EphemeralResult ¶ added in v1.222.0
EphemeralResult is the result of a one-shot container execution.
func RunEphemeralContainer ¶ added in v1.222.0
func RunEphemeralContainer(ctx context.Context, runtime Runtime, config *EphemeralConfig) (*EphemeralResult, error)
RunEphemeralContainer creates, starts, execs, and optionally removes a container.
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 HealthCheck ¶ added in v1.222.0
type HealthCheck struct {
Cmd string // shell command for --health-cmd ("" when Disable).
Interval string
Timeout string
Retries int
StartPeriod string
StartInterval string
Disable bool
}
HealthCheck is the resolved health check for a container. Cmd is the shell command run by `--health-cmd`; when Disable is set the container is created with `--no-healthcheck` and the remaining fields are ignored. Duration fields are Go duration strings forwarded verbatim to the runtime.
func HealthCheckFromStep ¶ added in v1.222.0
func HealthCheckFromStep(step *schema.ContainerRunStep) *HealthCheck
HealthCheckFromStep maps a run step's healthcheck spec onto a runtime HealthCheck, resolving the Compose `test` form (a bare string or a list whose first element is `NONE`, `CMD`, or `CMD-SHELL`) into a single shell command. Returns nil when no healthcheck is configured (the container then inherits any image healthcheck). It is shared by the container component and the emulator kind so both translate `healthcheck:` identically.
type ImageInfo ¶ added in v1.222.0
type ImageInfo struct {
ID string
RepoTags []string
RepoDigests []string
Size int64
Created string
Architecture string
Os string
Author string
Labels map[string]string
Env []string
Cmd []string
Entrypoint []string
ExposedPorts []string
StopSignal string
StorageDriver string
LayerDigests []string
Layers int
RawInspectJSON string
}
ImageInfo contains metadata about a local container image.
type ImageSummaryOptions ¶ added in v1.223.0
ImageSummaryOptions controls the rich CI Markdown summary for a built or pushed container image.
type Info ¶
type Info struct {
ID string
Name string
Image string
Status string // running, stopped, exited, etc.
Health string // healthy, unhealthy, starting, or "" when no healthcheck.
Created time.Time
Ports []PortBinding
Networks []string
NetworkIPs map[string]string
Labels map[string]string
}
Info represents container state information.
func FindInstance ¶ added in v1.222.0
func FindInstance(ctx context.Context, runtime Runtime, stack, componentType, component string) (*Info, bool, error)
FindInstance discovers a long-lived container for a component instance by its canonical instance label. It returns the container info and whether a match was found.
type Instance ¶ added in v1.222.0
Instance identifies a long-lived container by its component coordinates (stack, component type, and component name) — the same triple FindInstance uses for label-based discovery.
type Named ¶ added in v1.222.0
type Named struct {
// AlreadyRunning is true when Up found the instance already running and made
// no change.
AlreadyRunning bool
// contains filtered or unexported fields
}
Named is a started (or dry-run) long-lived container component instance.
func Up ¶ added in v1.222.0
func Up(ctx context.Context, config *NamedConfig) (*Named, error)
Up reconciles the desired long-lived container for a component instance: if it already exists and is running it is left untouched; if it exists but is stopped it is started; otherwise it is created (with canonical labels) and started. Discovery is by the canonical instance label, never local state.
func UpWithRuntime ¶ added in v1.222.0
UpWithRuntime reconciles the desired long-lived container against an already-detected runtime. Callers that own runtime detection (e.g. to forward a resolved registry-auth environment) use this directly; Up is the convenience wrapper that detects the runtime itself.
type NamedConfig ¶ added in v1.222.0
type NamedConfig struct {
// Canonical identity — drives the runtime name and labels.
Stack string
ComponentType string
Component string
// Container spec.
Image string
Command []string
Ports []PortBinding
Networks []NetworkAttachment
Mounts []Mount
Env map[string]string
User string
Labels map[string]string // extra labels, merged over the canonical instance labels
RunArgs []string
Privileged bool // run the container in privileged mode
Host bool // grant access to the host container runtime (Docker-out-of-Docker)
Restart *RestartPolicy // restart policy (nil = runtime default)
HealthCheck *HealthCheck // health check (nil = inherit image healthcheck)
// Runtime selection and behavior.
RuntimeName string // preferred runtime: "docker" | "podman" | "" (auto-detect)
RuntimeAutoStart bool // auto-init/start the Podman machine when needed
RuntimeEnv []string // environment forwarded to EnvSetter runtimes (e.g. registry auth)
PullPolicy string // missing | always | never
DryRun bool
}
NamedConfig describes a long-lived, label-discovered container component instance. The container is named and labeled from the canonical component instance address (<stack>/<component_type>/<component>), so all subsequent lifecycle operations discover it by label rather than by local state.
type NetworkAttachment ¶ added in v1.223.0
NetworkAttachment describes a container network membership created at container-create time, including DNS aliases scoped to that network.
type NetworkEnsurer ¶ added in v1.222.0
type NetworkEnsurer interface {
// EnsureNetwork creates the named user-defined network, treating an
// already-existing network as success.
EnsureNetwork(ctx context.Context, name string) error
}
NetworkEnsurer is an optional Runtime capability: it idempotently creates a user-defined container network. Emulators in the same stack join one such network so they can reach each other by component name (container DNS) — e.g. a GitOps controller running in the k3s emulator resolving the Gitea emulator at `http://gitserver:3000`. Runtimes that don't implement it simply skip the shared network; containers then fall back to the default bridge, where cross-container name resolution is unavailable (single-emulator use is unaffected, since host port publishing still works).
type PodmanRuntime ¶
type PodmanRuntime struct {
// contains filtered or unexported fields
}
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 connects to a running container's main process (PID 1) via `podman attach`.
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) EnsureNetwork ¶ added in v1.222.0
func (p *PodmanRuntime) EnsureNetwork(ctx context.Context, name string) error
EnsureNetwork idempotently creates a user-defined podman network. It implements NetworkEnsurer so emulators in a stack can share a network and resolve each other by component name.
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) ImageInspect ¶ added in v1.222.0
ImageInspect returns metadata for a local container image.
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.
func (*PodmanRuntime) Push ¶ added in v1.222.0
func (p *PodmanRuntime) Push(ctx context.Context, image string) (*PushResult, error)
Push pushes a container image.
func (*PodmanRuntime) SetEnv ¶ added in v1.222.0
func (p *PodmanRuntime) SetEnv(env []string)
SetEnv sets the environment for podman CLI subprocesses launched by this runtime. See EnvSetter for the rationale.
func (*PodmanRuntime) Shell ¶ added in v1.222.0
func (p *PodmanRuntime) Shell(ctx context.Context, containerID string, opts *ShellOptions) error
Shell opens an interactive shell in a running container (a new shell process via `exec`).
func (*PodmanRuntime) Start ¶
func (p *PodmanRuntime) Start(ctx context.Context, containerID string) error
Start starts a container.
type PortBinding ¶
PortBinding represents a port mapping.
type PushResult ¶ added in v1.222.0
PushResult contains metadata returned by a container image push.
type RestartPolicy ¶ added in v1.222.0
type RestartPolicy struct {
Policy string // no, always, on-failure, unless-stopped.
MaxRetries int // on-failure only.
}
RestartPolicy is the resolved restart policy for a long-lived container. It maps to the docker/podman `--restart` flag (`<policy>[:<max_retries>]`).
func RestartPolicyFromStep ¶ added in v1.222.0
func RestartPolicyFromStep(step *schema.ContainerRunStep) *RestartPolicy
RestartPolicyFromStep maps a run step's restart spec onto a runtime RestartPolicy, or nil when none is configured (the runtime then uses its default of `no`). It is shared by the container component and the emulator kind so both translate `restart:` identically.
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
// Shell opens an interactive shell in a running container (a new shell
// process via `exec`). Used to "shell into" a container.
Shell(ctx context.Context, containerID string, opts *ShellOptions) error
// Attach connects local stdin/stdout/stderr to a running container's main
// process (PID 1) via `docker/podman attach`. Unlike Shell, it does not
// start a new process — it attaches to the existing one (Docker/Compose
// `attach` semantics).
Attach(ctx context.Context, containerID string, opts *AttachOptions) error
// Image operations
Pull(ctx context.Context, image string) error
Tag(ctx context.Context, source, target string) error
Push(ctx context.Context, image string) (*PushResult, error)
ImageInspect(ctx context.Context, image string) (*ImageInfo, 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.
func DetectRuntimeWithPreference ¶ added in v1.222.0
DetectRuntimeWithPreference detects a runtime, optionally requiring a specific runtime.
func DetectRuntimeWithPreferenceAndRecovery ¶ added in v1.222.0
func DetectRuntimeWithPreferenceAndRecovery(ctx context.Context, preferred string, autoStart bool) (Runtime, error)
DetectRuntimeWithPreferenceAndRecovery detects a runtime and optionally initializes/starts Podman when Podman is the selected runtime.
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 Sandbox ¶ added in v1.222.0
type Sandbox struct {
// contains filtered or unexported fields
}
Sandbox is a started or dry-run workflow sandbox.
func StartSandbox ¶ added in v1.222.0
func StartSandbox(ctx context.Context, config *SandboxConfig) (*Sandbox, error)
StartSandbox detects the runtime, cleans up stopped stale sandboxes, creates, and starts the workflow sandbox.
func (*Sandbox) Cleanup ¶ added in v1.222.0
Cleanup removes the sandbox according to the configured cleanup policy.
type SandboxConfig ¶ added in v1.222.0
type SandboxConfig struct {
Name string
Workflow string
WorkflowPath string
RunID string
RuntimeName string
RuntimeAutoStart bool
Image string
WorkspaceHostPath string
WorkspaceFolder string
WorkspaceReadOnly bool
Mounts []Mount
Ports []PortBinding
Env []string
RuntimeEnv []string
User string
Labels map[string]string
RunArgs []string
PullPolicy string
CleanupPolicy string
DryRun bool
}
SandboxConfig describes a long-lived workflow sandbox container.
func NewWorkflowSandboxConfig ¶ added in v1.222.0
func NewWorkflowSandboxConfig(workflow, workflowPath, workspaceHostPath string) SandboxConfig
NewWorkflowSandboxConfig builds a sandbox config with stable labels and a unique container name for a workflow execution.
type ShellOptions ¶ added in v1.222.0
type ShellOptions 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
}
ShellOptions represents options for opening an interactive shell in a container (via `exec`). Shell/ShellArgs select the shell program and its arguments; an empty Shell defaults to /bin/bash.
type Type ¶
type Type string
Type represents the container runtime type.
func GetRuntimeType ¶
GetRuntimeType returns the type of a runtime instance.