Help us shape the future of Go! Take the 2026 Go Developer Survey

container

package
v1.222.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2026 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteAttach

func ExecuteAttach(ctx context.Context, info *schema.ConfigAndStacksInfo) error

ExecuteAttach attaches local stdin/stdout/stderr to the component container's main process (PID 1), mirroring `docker/podman attach`. Unlike `exec`, it does not start a new shell — it connects to the existing process. Detach with the runtime's detach keys (Ctrl-P Ctrl-Q), which leaves the container running.

func ExecuteBuild

func ExecuteBuild(ctx context.Context, info *schema.ConfigAndStacksInfo) error

ExecuteBuild builds the component image from the build configuration.

func ExecuteBulk

func ExecuteBulk(ctx context.Context, info *schema.ConfigAndStacksInfo, verb string) error

ExecuteBulk resolves the set of target container components and runs the verb against each one, continuing on error and aggregating failures into a single summary. Targets come from `--all` (all components, optionally scoped by --stack) or from an interactive picker (stack, then components) when no component was given.

func ExecuteDown

func ExecuteDown(ctx context.Context, info *schema.ConfigAndStacksInfo) error

ExecuteDown stops and removes the long-lived container.

func ExecuteExec

func ExecuteExec(ctx context.Context, info *schema.ConfigAndStacksInfo, command []string) error

ExecuteExec runs a command in the component's container. Args after `--` form the command; defaults to a shell.

func ExecuteList

func ExecuteList(ctx context.Context, info *schema.ConfigAndStacksInfo) error

ExecuteList lists all container components across stacks (optionally filtered by --stack) with their running state, discovered by label. This is the container-specific listing; running state is intentionally NOT surfaced by the generic `atmos list components` (which treats all component kinds uniformly).

func ExecuteLogs

func ExecuteLogs(ctx context.Context, info *schema.ConfigAndStacksInfo) error

ExecuteLogs streams logs from a single component's container (no follow, all lines). The richer multi-component / follow behavior lives in ExecuteLogsWithOptions (logs.go); this thin entry point is kept for callers and tests that stream one component with defaults.

func ExecuteLogsWithOptions

func ExecuteLogsWithOptions(ctx context.Context, info *schema.ConfigAndStacksInfo, opts logsOptions) error

ExecuteLogsWithOptions streams logs for one or many container components. A component argument streams just that one; `--all` or no component selects many (all components, or an interactive picker). With `--follow` and multiple components, logs are streamed concurrently and each line is prefixed with the component name; without `--follow` they are printed sequentially.

func ExecutePs

func ExecutePs(ctx context.Context, info *schema.ConfigAndStacksInfo) error

ExecutePs reports the running state of a single component's container, including its health when a health check is configured. The no-argument listing is handled by ExecuteList.

func ExecutePull

func ExecutePull(ctx context.Context, info *schema.ConfigAndStacksInfo) error

ExecutePull pulls the component image.

func ExecutePush

func ExecutePush(ctx context.Context, info *schema.ConfigAndStacksInfo) error

ExecutePush pushes the component image to its registry. It sends every configured build tag (so registry-qualified tags in `build.tags` push to multiple registries in one operation), falling back to the single top-level image when no build tags are set. Pushes happen in order and fail fast.

func ExecuteRestart

func ExecuteRestart(ctx context.Context, info *schema.ConfigAndStacksInfo) error

ExecuteRestart stops then starts the component's container.

func ExecuteRm

func ExecuteRm(ctx context.Context, info *schema.ConfigAndStacksInfo) error

ExecuteRm removes the component's container.

func ExecuteRun

func ExecuteRun(ctx context.Context, info *schema.ConfigAndStacksInfo) error

ExecuteRun runs the component as a one-shot foreground container (run).

func ExecuteStart

func ExecuteStart(ctx context.Context, info *schema.ConfigAndStacksInfo) error

ExecuteStart starts the component's existing (stopped) container in place, discovered by label. It is the inverse of stop: unlike `up`, it never creates or recreates the container — if none exists, `up` is the way to create it.

func ExecuteStop

func ExecuteStop(ctx context.Context, info *schema.ConfigAndStacksInfo) error

ExecuteStop stops the component's container without removing it.

func ExecuteUp

func ExecuteUp(ctx context.Context, info *schema.ConfigAndStacksInfo) error

ExecuteUp creates or starts the long-lived named container (run).

Types

type Config

type Config struct {
	// BasePath is the base directory for container component assets.
	BasePath string `mapstructure:"base_path"`
}

Config is the global configuration for the container component kind, stored under `components.container` in atmos.yaml and read via the Plugins map.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the default global container component configuration.

type ContainerComponentProvider

type ContainerComponentProvider struct{}

ContainerComponentProvider implements component.ComponentProvider for the container component kind: a stack-scoped, Atmos-native, persistent container whose lifecycle is discovered by labels derived from the canonical component instance address.

func (*ContainerComponentProvider) Execute

Execute dispatches a container subcommand to the matching executor. Bulk-capable lifecycle verbs fan out to ExecuteBulk when `--all` is set or no component was given (interactive picker); otherwise they run against the single component.

func (*ContainerComponentProvider) GenerateArtifacts

GenerateArtifacts is a no-op for container components (no generated files).

func (*ContainerComponentProvider) GetAvailableCommands

func (p *ContainerComponentProvider) GetAvailableCommands() []string

GetAvailableCommands returns the lifecycle verbs supported by container components.

func (*ContainerComponentProvider) GetBasePath

func (p *ContainerComponentProvider) GetBasePath(atmosConfig *schema.AtmosConfiguration) string

GetBasePath returns the base directory path for container components.

func (*ContainerComponentProvider) GetGroup

func (p *ContainerComponentProvider) GetGroup() string

GetGroup returns the component group for categorization.

func (*ContainerComponentProvider) GetType

func (p *ContainerComponentProvider) GetType() string

GetType returns the component type identifier.

func (*ContainerComponentProvider) ListComponents

func (p *ContainerComponentProvider) ListComponents(_ context.Context, _ string, stackConfig map[string]any) ([]string, error)

ListComponents discovers all container components in a stack.

func (*ContainerComponentProvider) ValidateComponent

func (p *ContainerComponentProvider) ValidateComponent(config map[string]any) error

ValidateComponent validates container component configuration. A real (non-abstract) component must declare an image or a build.

type ContainerSpec

type ContainerSpec struct {
	Image       string
	Build       *schema.ContainerBuildStep
	Run         *schema.ContainerRunStep
	Composition string
}

ContainerSpec is the resolved, per-instance container component configuration. Its build/run shapes reuse the workflow container-step structs so component and step configuration stay consistent. These are first-class component sections (siblings of `composition`/`env`/`metadata`), NOT nested under `vars`.

func FromComponentSection

func FromComponentSection(section map[string]any) (ContainerSpec, error)

FromComponentSection decodes the resolved (merged, templated) component section into a ContainerSpec, reading the first-class top-level keys `image`, `build`, `run`, and `composition`. Container application env comes from the component's `env:` section (resolved with secrets), not from `run`.

func (*ContainerSpec) CommandArgs

func (s *ContainerSpec) CommandArgs() ([]string, error)

CommandArgs tokenizes the run command string into argv using shell-style quoting so quoted arguments (e.g. `sh -c "echo hi"`) survive intact when passed directly as argv (as `up` does, unlike `run` which wraps in `/bin/sh -lc`). An empty command yields nil so the image's default ENTRYPOINT/CMD is used. A malformed command (e.g. an unbalanced quote) is a config error.

func (*ContainerSpec) HealthCheck

func (s *ContainerSpec) HealthCheck() *ctr.HealthCheck

HealthCheck maps the run 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).

func (*ContainerSpec) HostRuntime

func (s *ContainerSpec) HostRuntime() bool

HostRuntime reports whether the container needs access to the host container runtime (Docker-out-of-Docker), set via `run.runtime.host: true`.

func (*ContainerSpec) Mounts

func (s *ContainerSpec) Mounts() []ctr.Mount

Mounts maps the run mount specs onto runtime Mounts.

func (*ContainerSpec) Ports

func (s *ContainerSpec) Ports() []ctr.PortBinding

Ports maps the structured run port specs onto runtime PortBindings.

func (*ContainerSpec) PushRefs

func (s *ContainerSpec) PushRefs() []string

PushRefs returns the image references that `push` should send. When a build with tags is configured it returns every build tag (deduped, order-preserving) — so listing registry-qualified tags in `build.tags` pushes the image to multiple registries in one operation. Otherwise it returns the single top-level image (or nil when neither is set).

func (*ContainerSpec) RestartPolicy

func (s *ContainerSpec) RestartPolicy() *ctr.RestartPolicy

RestartPolicy maps the run restart spec onto a runtime RestartPolicy, or nil when none is configured (the runtime then uses its default of `no`).

func (*ContainerSpec) ToBuildConfig

func (s *ContainerSpec) ToBuildConfig() *ctr.BuildConfig

ToBuildConfig maps the build spec onto a runtime BuildConfig.

func (*ContainerSpec) ValidateRun

func (s *ContainerSpec) ValidateRun() error

ValidateRun checks the run 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 `run` is unset.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL