compose

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Version  string             `yaml:"version"`
	Services map[string]Service `yaml:"services"`
}

Config represents the top-level docker-compose.yml structure.

func Parse

func Parse(path string) (*Config, error)

Parse reads and unmarshals the compose file at path into a Config.

type DependsOn

type DependsOn map[string]DependsOnCondition

DependsOn supports both forms of the depends_on key:

depends_on: [db, redis]           ← list form
depends_on:
  db:
    condition: service_healthy    ← map form

func (*DependsOn) UnmarshalYAML

func (d *DependsOn) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML handles both the list and map forms of depends_on.

type DependsOnCondition

type DependsOnCondition struct {
	Condition string `yaml:"condition"`
}

DependsOnCondition holds the optional condition for a single dependency.

type Healthcheck

type Healthcheck struct {
	Test          HealthcheckTest `yaml:"test"`
	Interval      string          `yaml:"interval"`
	Timeout       string          `yaml:"timeout"`
	StartPeriod   string          `yaml:"start_period"`
	StartInterval string          `yaml:"start_interval"`
	Retries       int             `yaml:"retries"`
	Disable       bool            `yaml:"disable"`
}

Healthcheck mirrors the docker-compose healthcheck block.

type HealthcheckTest added in v0.4.0

type HealthcheckTest []string

HealthcheckTest supports both string and list forms of healthcheck.test:

test: curl -f http://localhost/          → ["CMD-SHELL", "..."]
test: ["CMD", "curl", "-f", "http://…"]

func (*HealthcheckTest) UnmarshalYAML added in v0.4.0

func (t *HealthcheckTest) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML handles scalar (CMD-SHELL) and sequence forms of test.

type Ports added in v0.5.0

type Ports []string

Ports supports short-form strings and long-form maps from `docker compose config`:

ports: ["8080:80"]
ports: [{target: 80, published: "8080", protocol: tcp}]

func (*Ports) UnmarshalYAML added in v0.5.0

func (p *Ports) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML accepts scalar short-form and long-form mapping port entries.

type Service

type Service struct {
	Image       string            `yaml:"image"`
	Build       interface{}       `yaml:"build"`
	DependsOn   DependsOn         `yaml:"depends_on"`
	Healthcheck *Healthcheck      `yaml:"healthcheck"`
	Restart     string            `yaml:"restart"`
	Ports       Ports             `yaml:"ports"`
	Environment map[string]string `yaml:"environment"`
}

Service represents a single service definition.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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