compose

package
v0.51.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TopologicalSort

func TopologicalSort(services map[string]Service) ([]string, error)

TopologicalSort returns service names in dependency order (dependencies first). Returns an error if a dependency cycle is detected.

Types

type File

type File struct {
	// Version must be "1".
	Version string `yaml:"version"`
	// Services maps service name to its definition.
	Services map[string]Service `yaml:"services"`
	// Networks maps network name to its definition.
	Networks map[string]Network `yaml:"networks"`
	// Volumes maps volume name to its configuration.
	// Top-level volumes are created on "compose up" and optionally
	// removed on "compose down --volumes".
	Volumes map[string]VolumeConfig `yaml:"volumes"`
}

File is a parsed jerboa compose file.

func Parse

func Parse(data []byte) (File, error)

Parse decodes a compose YAML document and validates it.

type Network

type Network struct {
	Driver string `yaml:"driver"`
	Subnet string `yaml:"subnet,omitempty"`
}

Network describes a logical network.

type Service

type Service struct {
	Image       string   `yaml:"image"`
	Memory      string   `yaml:"memory"`
	CPUs        int      `yaml:"cpus"`
	DependsOn   []string `yaml:"depends_on"`
	Networks    []string `yaml:"networks"`
	Environment []string `yaml:"environment"`
	Ports       []string `yaml:"ports"`
	Volumes     []string `yaml:"volumes"`
	HealthCheck string   `yaml:"health_check,omitempty"`
	Restart     string   `yaml:"restart,omitempty"`
	Replicas    int      `yaml:"replicas,omitempty"`
	Strategy    string   `yaml:"strategy,omitempty"`
}

Service describes a single unikernel service.

type State

type State struct {
	Project         string            `json:"project"`
	Services        map[string]string `json:"services"`
	ServiceNetworks map[string]string `json:"service_networks,omitempty"`
	ServiceIPs      map[string]string `json:"service_ips,omitempty"`
	CreatedVolumes  []string          `json:"created_volumes,omitempty"`
	CreatedNetworks []string          `json:"created_networks,omitempty"`
	// ScalableServices tracks services deployed via Service.Run (replicas > 1).
	// Key is service name, value is the service name (same as key).
	ScalableServices map[string]string `json:"scalable_services,omitempty"`
}

State records running VM IDs and created volumes for a compose project.

type VolumeConfig

type VolumeConfig struct {
	// Size is the volume size as a human-readable string (e.g. "512M", "1G").
	// Defaults to "1G" if empty.
	Size string `yaml:"size"`
}

VolumeConfig describes a named volume defined at the top level of a compose file.

func (VolumeConfig) DefaultSize

func (vc VolumeConfig) DefaultSize() string

DefaultSize returns the volume size, falling back to "1G".

Jump to

Keyboard shortcuts

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