compose

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package compose resolves a repository's Docker Compose configuration with `docker compose config` and exposes the parts provr checks and overrides. It parses JSON only, and it generates YAML for the compose override (Override); YAML parsing stays confined to internal/config and internal/core.

Index

Constants

View Source
const MinVersion = "2.24.0"

MinVersion is the minimum supported Docker Compose version.

Variables

View Source
var (
	// ErrDockerMissing means docker or its compose plugin is not available.
	ErrDockerMissing = errors.New("docker compose not found: " + installHint)
	// ErrComposeTooOld means the installed compose is older than MinVersion.
	ErrComposeTooOld = errors.New("docker compose is too old: " + installHint)
)

Functions

func CheckVersion

func CheckVersion(ctx context.Context, runner execx.Runner) (string, error)

CheckVersion returns the installed compose version (as reported, minus a leading "v") or an error when it is missing or older than MinVersion.

func Override

func Override(in OverrideInput) ([]byte, error)

Override renders the compose override file. Every project service gets `container_name: !reset null`, `ports: !reset []` and the provr labels; fragment services, networks and volumes are added alongside. Fragment services without networks join the union of the exposed services' networks. Provr labels win over any label of the same key on a fragment service. Fragment Files are never rendered. Output is deterministic.

Types

type EnvFile

type EnvFile struct {
	Path     string
	Required bool
}

EnvFile is an env_file entry.

type Mount

type Mount struct {
	Type   string
	Source string
	Target string
}

Mount is a service volume entry.

type Network

type Network struct {
	Name     string
	External bool
}

Network is a top-level Compose network.

type Options

type Options struct {
	// RepoRoot is the project directory.
	RepoRoot string
	// Files are compose files passed with -f.
	Files []string
	// Profiles are passed with --profile.
	Profiles []string
	// EnvFile is passed with --env-file only when it exists.
	EnvFile string
}

Options configures Resolve.

type OverrideInput

type OverrideInput struct {
	Project  *Project             // resolved model from Resolve/Parse
	Labels   map[string]string    // from core.BuildLabels
	Expose   []core.ServicePort   // the project's expose entries
	Fragment core.ComposeFragment // from the Exposer's Plan
}

OverrideInput holds what the override is generated from.

type Port

type Port struct {
	Target    int
	Published string
	HostIP    string
}

Port is a published port mapping.

type Project

type Project struct {
	Services map[string]Service
	Networks map[string]Network
	Volumes  map[string]Volume
}

Project is a resolved Compose project.

func Parse

func Parse(data []byte) (*Project, error)

Parse decodes `docker compose config --format json` output.

func Resolve

func Resolve(ctx context.Context, runner execx.Runner, opts Options) (*Project, error)

Resolve runs `docker compose config` and parses the result. It needs no Docker daemon and tolerates missing gitignored env_files.

type Service

type Service struct {
	Image             string
	ContainerName     string
	Ports             []Port
	NetworkMode       string
	Networks          []string
	Mounts            []Mount
	EnvFiles          []EnvFile
	HasHealthcheck    bool
	MemoryReservation int64
	MemoryLimit       int64
	Profiles          []string
}

Service is a resolved Compose service.

type Volume

type Volume struct {
	Name     string
	External bool
}

Volume is a top-level Compose volume.

Jump to

Keyboard shortcuts

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