compose

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: MIT Imports: 7 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 locates compose files and inspects how they declare ports.

Index

Constants

This section is empty.

Variables

View Source
var OverrideNames = []string{
	"compose.override.yaml", "compose.override.yml",
	"docker-compose.override.yaml", "docker-compose.override.yml",
}

OverrideNames is exported so provisioning copies exactly the files this package detects; two lists drifting apart is how a detected override once ended up referenced by -f without existing in the worktree.

Functions

func Base

func Base(dir string) (string, error)

Base is the first compose file docker would read. Its only caller asks whether the project has a stack at all; nothing reads the file itself.

func Files

func Files(dir string) ([]string, error)

Files reproduces docker compose's auto-detection, needed whenever an extra -f is passed since that forces every file to be named explicitly.

func PinnedContainerNames added in v0.4.3

func PinnedContainerNames(dir string) ([]string, error)

PinnedContainerNames lists the services whose compose file fixes their container_name. Ports, volumes and the compose project name are rebased, a container_name is not: docker refuses a second container carrying it, so the main stack and a worktree stack cannot both run.

func PortLabel

func PortLabel(s ServicePort) string

PortLabel distinguishes the several ports of one service, using the part of the variable name that is not the service name: MAILHOG_WEB_PORT on service mailhog becomes "web".

func ServiceImage added in v0.4.0

func ServiceImage(dir, service string) (string, bool)

ServiceImage returns the image a service runs, reading the project's merged compose configuration: an override redefining the service wins.

func Services added in v0.3.0

func Services(dir string) ([]string, error)

Services lists the service names declared across the project's compose files, in declaration order, then alphabetically for what the overrides add.

Types

type ServicePort

type ServicePort struct {
	Service string
	// Var is the environment variable wtc overrides, empty when the port is
	// hardcoded and therefore not isolatable.
	Var       string
	HostIP    string // interface the project binds to (IPv4), empty when unset
	Host      string // host port declared as the default
	Container string // container side, which is what tells a web port apart
}

func MergedServicePorts

func MergedServicePorts(dir string) ([]ServicePort, error)

MergedServicePorts reads the base file then lets the project's own override win, service by service. A project that already remaps its ports on purpose (to avoid a clash on the machine) must keep that mapping as the reference, otherwise rebasing from the base file would silently undo it.

func ServicePorts

func ServicePorts(path string) ([]ServicePort, error)

ServicePorts lists the published ports per service, from that one file only: merging across files is MergedServicePorts' job. The file is walked as a YAML tree rather than decoded into structs, so compose's own tags (!override, !reset) and anchors pass through instead of failing the parse.

func (ServicePort) IsWeb

func (s ServicePort) IsWeb() bool

Jump to

Keyboard shortcuts

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