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

compose

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package compose loads docker-compose projects into the IR.

The compose-spec loader does the parsing, so QuadDoc inherits its handling of interpolation, extends, merge order, and the rest. What this package adds is the mapping onto Quadlet's model, and honesty about what does not map: an unsupported key produces a finding, never a silent drop.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dependency

type Dependency struct {
	Service string
	// Condition is `service_started`, `service_healthy`, or
	// `service_completed_successfully`.
	Condition string
	// Required is false when compose may start the service without it.
	Required bool
}

Dependency is one `depends_on` edge.

type EnvVar

type EnvVar struct {
	Name  string
	Value string
}

EnvVar is one environment assignment.

type HealthCheck

type HealthCheck struct {
	Test        []string
	Interval    string
	Timeout     string
	StartPeriod string
	Retries     int
	Disabled    bool
}

HealthCheck is a compose healthcheck.

type Mount

type Mount struct {
	// Type is `bind`, `volume`, or `tmpfs`.
	Type string
	// Source is an absolute host path for a bind, or a volume name.
	Source string
	Target string
	// ReadOnly is the `:ro` flag.
	ReadOnly bool
	// SELinux carries a `z` or `Z` if the compose file already set one.
	SELinux string
	// Propagation is a bind's `propagation`, e.g. `rshared`.
	Propagation string
	// NoCopy is a volume's `nocopy`.
	NoCopy bool
	// TmpfsSize and TmpfsMode are a tmpfs mount's `size` in bytes and `mode`,
	// zero when unset.
	TmpfsSize int64
	TmpfsMode uint32
}

Mount is one volume entry, already resolved by the compose loader.

type Network

type Network struct {
	// Name is the compose key. ObjectName is the Podman network name: compose's
	// `name:` when set, otherwise `<project>_<key>` as compose itself names it.
	Name       string
	ObjectName string
	Driver     string
	Internal   bool
	Labels     map[string]string
	External   bool
	// Subnets are the configured IPAM subnets.
	Subnets []string
	Gateway string
}

Network is a declared network.

type Port

type Port struct {
	HostIP    string
	Published string
	Target    int
	Protocol  string
}

Port is one published port.

func (Port) PublishedPort

func (p Port) PublishedPort() string

PublishedPort renders a port for `PublishPort=`.

type Project

type Project struct {
	// Name is the compose project name, used to name the generated network.
	Name string
	// Services are the compose services, sorted by name for determinism.
	Services []Service
	// Volumes are the declared named volumes, sorted.
	Volumes []Volume
	// Networks are the declared networks, sorted.
	Networks []Network
	// Unsupported records compose features that have no faithful Quadlet
	// translation, so they can be reported rather than dropped.
	Unsupported []Unsupported
	// WorkingDir is the directory the compose file was loaded from.
	WorkingDir string
}

Project is a loaded compose project, together with what could not be translated.

func Load

func Load(path string) (*Project, error)

Load reads a compose file and normalises it.

type Service

type Service struct {
	Name        string
	Image       string
	Command     []string
	Entrypoint  []string
	User        string
	WorkingDir  string
	Hostname    string
	Restart     string
	Environment []EnvVar
	Volumes     []Mount
	Ports       []Port
	// NetworkMode is compose's `network_mode`, empty when the service joins
	// Networks instead.
	NetworkMode string
	Networks    []ServiceNetwork
	DependsOn   []Dependency
	HealthCheck *HealthCheck
	CapAdd      []string
	CapDrop     []string
	Devices     []string
	DNS         []string
	Labels      map[string]string
	GroupAdd    []string
	ReadOnly    bool
	Privileged  bool
	ShmSize     string
	StopSignal  string
	Sysctls     map[string]string
	Tmpfs       []string
	// ContainerName is compose's `container_name`, empty when unset.
	ContainerName string
	// ExtraHosts are `host:ip` mappings, sorted by host.
	ExtraHosts []string
	// Init is compose's `init`, nil when unset.
	Init   *bool
	UserNS string
	// StopTimeout is `stop_grace_period` in whole seconds, rounded up; nil
	// when unset.
	StopTimeout *int
	DNSSearch   []string
	// Ulimits are `name=soft[:hard]` values, sorted by name.
	Ulimits []string
	// Memory is `mem_limit` in bytes, empty when unset.
	Memory string
	// Pull is the Podman pull policy compose's `pull_policy` maps to, empty
	// when unset or when it has no Podman equivalent.
	Pull        string
	LogDriver   string
	LogOptions  map[string]string
	Annotations map[string]string
	PidsLimit   string
	// PID and IPC are compose's `pid` and `ipc` namespace modes.
	PID string
	IPC string
}

Service is one compose service.

type ServiceNetwork added in v0.2.0

type ServiceNetwork struct {
	Name        string
	Aliases     []string
	IPv4Address string
	IPv6Address string
}

ServiceNetwork is one entry of a service's `networks:`, naming a declared network by its compose key.

type Unsupported

type Unsupported struct {
	// Service is the service it appeared on, empty for a top-level key.
	Service string
	// Key is the compose key, e.g. `build`.
	Key string
	// Reason explains why it cannot be translated, and what to do instead.
	Reason string
}

Unsupported is a compose feature with no faithful Quadlet translation.

type Volume

type Volume struct {
	// Name is the compose key. ObjectName is the Podman volume name: compose's
	// `name:` when set, otherwise the key.
	Name       string
	ObjectName string
	Driver     string
	Options    map[string]string
	Labels     map[string]string
	External   bool
}

Volume is a declared named volume.

Jump to

Keyboard shortcuts

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