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

compose

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InjectSharedNetwork

func InjectSharedNetwork(yamlContent []byte, networkName string) ([]byte, bool, error)

InjectSharedNetwork rewrites a compose YAML to declare the given shared external network and attach every service that has endpoint labels to it. Returns new bytes, whether any change was made, and an error.

func ValidateComposeSecurity

func ValidateComposeSecurity(cfg *AppConfig) []string

ValidateComposeSecurity checks a parsed compose project for dangerous directives. Returns a list of violations. Empty list means safe.

Types

type AppConfig

type AppConfig struct {
	Name            string
	ComposePath     string
	Endpoints       []EndpointConfig
	BackupStrategy  string
	BackupSchedule  string
	BackupTarget    string
	BackupRetention string
	AlertCPU        string
	AlertMemory     string
	Registries      string
	AccessAllow     string
	RateLimit       RateLimitLabels
	Services        []ServiceConfig
	Project         *types.Project
}

AppConfig holds the parsed compose file config plus extracted simpledeploy labels.

func ParseFile

func ParseFile(path, appName string) (*AppConfig, error)

ParseFile parses the compose file at path and returns an AppConfig with appName as the name. simpledeploy.* labels are collected across all services; the first value found wins.

func (*AppConfig) PrimaryDomain

func (a *AppConfig) PrimaryDomain() string

PrimaryDomain returns the domain of the first endpoint, or empty string.

type EndpointConfig

type EndpointConfig struct {
	Domain  string `json:"domain"`
	Port    string `json:"port"`
	TLS     string `json:"tls"`
	Service string `json:"service"`
}

EndpointConfig holds config for a single endpoint (domain/port/tls bound to a service).

type LabelConfig

type LabelConfig struct {
	BackupStrategy  string
	BackupSchedule  string
	BackupTarget    string
	BackupRetention string
	AlertCPU        string
	AlertMemory     string
	Registries      string
	AccessAllow     string
	RateLimit       RateLimitLabels
}

LabelConfig holds all extracted simpledeploy.* labels (non-endpoint labels).

func ExtractLabels

func ExtractLabels(labels map[string]string) LabelConfig

ExtractLabels extracts non-endpoint simpledeploy.* labels from the provided map.

type PortMapping

type PortMapping struct {
	Host, Container, Protocol string
}

PortMapping represents a host:container port binding.

type RateLimitLabels

type RateLimitLabels struct {
	Requests, Window, By, Burst string
}

RateLimitLabels holds simpledeploy.ratelimit.* label values.

type ServiceConfig

type ServiceConfig struct {
	Name        string
	Image       string
	Ports       []PortMapping
	Environment map[string]string
	Volumes     []VolumeMount
	Restart     string
	Labels      map[string]string
	DependsOn   []string
	DeployMode  string
}

ServiceConfig is a simplified representation of a compose service.

func (*ServiceConfig) ScaleEligibility

func (s *ServiceConfig) ScaleEligibility() (bool, string)

ScaleEligibility reports whether the service can safely run with N>1 replicas. Returns (true, "") when scalable, (false, reason) otherwise.

Detection rules (in order):

  1. simpledeploy.scalable=false label forces non-scalable.
  2. simpledeploy.scalable=true label forces scalable (override).
  3. deploy.mode: global (one container per node).
  4. Any host-published port (would clash on the same host).
  5. Named volumes (typically stateful).
  6. Known stateful image (database, broker, etc.).

type VolumeMount

type VolumeMount struct {
	Source, Target, Type string
}

VolumeMount represents a service volume mount.

Jump to

Keyboard shortcuts

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