Documentation
¶
Overview ¶
Package compose locates compose files and inspects how they declare ports.
Index ¶
- Variables
- func Files(dir string) ([]string, error)
- func Has(dir string) bool
- func PinnedContainerNames(dir string) ([]string, error)
- func PortLabel(s ServicePort) string
- func ServiceImage(dir, service string) (string, bool)
- func Services(dir string) ([]string, error)
- func WithDependencies(dir string, services []string) ([]string, error)
- type ServicePort
Constants ¶
This section is empty.
Variables ¶
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 Files ¶
Files reproduces docker compose's auto-detection, needed whenever an extra -f is passed since that forces every file to be named explicitly.
func Has ¶ added in v0.17.1
Has says whether dir holds a compose file, which is whether it has a stack.
func PinnedContainerNames ¶ added in v0.4.3
PinnedContainerNames lists the services whose compose file fixes their container_name: ports, volumes and the project name are rebased, that is not, and docker refuses a second container carrying it.
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
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
Services lists the service names declared across the project's compose files, in declaration order, then alphabetically for what the overrides add.
func WithDependencies ¶ added in v0.17.0
WithDependencies adds to services what they declare in depends_on, transitively and across every compose file, which is what `compose up -d <services>` really starts. depends_on is either a list or a mapping.
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 already remapping a port on purpose must keep that mapping, or 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.
func (ServicePort) IsWeb ¶
func (s ServicePort) IsWeb() bool