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

convert

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package convert turns a compose project into what the Compose orchestrator creates on the Docker Engine: the create options of each container, its networks and volumes, and the state to wait for, the way docker compose does. It only computes: creating the objects is the orchestrator's job.

Index

Constants

View Source
const (
	ProjectLabel    = "com.docker.compose.project"
	ServiceLabel    = "com.docker.compose.service"
	NumberLabel     = "com.docker.compose.container-number"
	OneoffLabel     = "com.docker.compose.oneoff"
	ConfigHashLabel = "com.docker.compose.config-hash"
	NetworkLabel    = "com.docker.compose.network"
	VolumeLabel     = "com.docker.compose.volume"
)

Labels docker compose puts on what it creates.

Variables

This section is empty.

Functions

func Conditions

func Conditions(project *types.Project) map[string]Condition

Conditions gives each service the strongest state its dependants ask for. A service nothing depends on is waited for until it runs, and healthy when it has a healthcheck, as docker compose up --wait.

func ContainerName

func ContainerName(stack, service string, number int) string

ContainerName is the name of a service's container, as docker compose names it: <project>-<service>-<number>.

func Network

func Network(key string, network types.NetworkConfig, base map[string]string) (docker.NetworkSpec, error)

Network converts a compose network.

func Volume

func Volume(key string, config types.VolumeConfig, base map[string]string) *volume.Volume

Volume converts a compose volume.

Types

type Condition

type Condition string

Condition is the state a container must reach before the services depending on it start.

const (
	Started   Condition = "running"
	Healthy   Condition = "healthy"
	Completed Condition = "completed"
)

type File

type File struct {
	Path     string
	Data     []byte `json:"-"`
	Digest   digest.Digest
	UID, GID int
	Mode     os.FileMode
}

File is a config or a secret, copied into each container before it starts.

type ServiceSpec

type ServiceSpec struct {
	Name       string
	Replicas   int
	Config     *container.Config
	Host       *container.HostConfig
	Networking *network.NetworkingConfig
	Platform   *ocispec.Platform
	Files      []File
	// Hash identifies the spec: a container whose hash differs is recreated.
	Hash string
	// Wait is the state the containers must reach before the next level starts.
	Wait Condition
}

ServiceSpec is what every container of a compose service is created from.

func Service

func Service(project *types.Project, service types.ServiceConfig, base map[string]string) (*ServiceSpec, error)

Service converts a compose service into what each of its containers is created from.

Jump to

Keyboard shortcuts

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