compose

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2025 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultTagTemplate is the default tag template appended to images without a tag when building locally.
	// Format:
	// If the project workdir is a git repo: "2025-08-16-130734.84d33bb" or "2025-08-16-130734.84d33bb.dirty"
	// If not a git repo: "2025-08-16-130734" which is the current date and time.
	DefaultTagTemplate = `` /* 137-byte string literal not displayed */
	// DefaultImageTemplate is the default image template used when no image is specified.
	DefaultImageTemplate = "{{.Project}}/{{.Service}}:" + DefaultTagTemplate
)
View Source
const CaddyExtensionKey = "x-caddy"
View Source
const MachinesExtensionKey = "x-machines"
View Source
const PortsExtensionKey = "x-ports"

Variables

This section is empty.

Functions

func LoadProject

func LoadProject(ctx context.Context, paths []string, opts ...composecli.ProjectOptionsFn) (*types.Project, error)

LoadProject loads a Compose project from the default locations or the given paths.

func LoadProjectFromContent added in v0.15.0

func LoadProjectFromContent(
	ctx context.Context, content string, opts ...composecli.ProjectOptionsFn,
) (*types.Project, error)

LoadProjectFromContent loads a Compose project from the given YAML content.

func ProcessImageTemplates added in v0.14.0

func ProcessImageTemplates(project *types.Project) (*types.Project, error)

ProcessImageTemplates processes image names in services to expand Go template expressions using git metadata. If a service has no image specified, uses the default template {{.Project}}/{{.Service}}:{{.Tag}}. If a service has a build section and an image without a tag, appends the default tag template. Fully specified images are left unchanged.

Template context: ImageTemplateContext Template functions: gitsha(length?), gitdate(format, timezone?), date(format, timezone?)

Examples:

image: myapp:{{.Tag}}                        → myapp:2025-08-16-130734.84d33bb
image: registry.io/api:v1.0-{{gitsha 7}}     → registry.io/api:v1.0-84d33bb
image: worker:{{gitdate "2006-01-02"}}       → worker:2025-08-16
build: . / image: mybackend                  → mybackend:2025-08-16-130734.84d33bb
build: . / (no image)                        → myproject/myservice:2025-08-16-130734.84d33bb
image: postgres                              → postgres (unchanged)

func ServiceSpecFromCompose

func ServiceSpecFromCompose(project *types.Project, serviceName string) (api.ServiceSpec, error)

Types

type Caddy added in v0.11.1

type Caddy struct {
	Config string `yaml:"config" json:"config"`
}

func (*Caddy) DecodeMapstructure added in v0.11.1

func (c *Caddy) DecodeMapstructure(value any) error

DecodeMapstructure decodes x-caddy extension from either a string or an object. When x-caddy is a string, it's mapped directly to the Config field.

type Client

type Client interface {
	api.DNSClient
	deploy.Client
}

type Deployment

type Deployment struct {
	Client       Client
	Project      *types.Project
	SpecResolver *deploy.ServiceSpecResolver
	Strategy     deploy.Strategy
	// contains filtered or unexported fields
}

func NewDeployment

func NewDeployment(ctx context.Context, cli Client, project *types.Project) (*Deployment, error)

func NewDeploymentWithStrategy added in v0.11.0

func NewDeploymentWithStrategy(ctx context.Context, cli Client, project *types.Project, strategy deploy.Strategy) (*Deployment, error)

func (*Deployment) Plan

func (*Deployment) Run

func (d *Deployment) Run(ctx context.Context) error

func (*Deployment) ServiceSpec

func (d *Deployment) ServiceSpec(name string) (api.ServiceSpec, error)

ServiceSpec returns the service specification for the given compose service that is ready for deployment.

type ImageTemplateContext added in v0.14.0

type ImageTemplateContext struct {
	// Project is the project name.
	Project string
	// Service is the service name where the image is defined.
	Service string
	// Git is the git repo state.
	Git gitutil.GitState
	// Tag is the rendered DefaultTagTemplate used for images without a tag.
	Tag string
}

ImageTemplateContext contains structured data for image template processing.

type MachinesSource added in v0.10.0

type MachinesSource []string

MachinesSource represents the parsed x-machines extension data as slice of strings

func (*MachinesSource) DecodeMapstructure added in v0.10.0

func (m *MachinesSource) DecodeMapstructure(value interface{}) error

DecodeMapstructure implements custom decoding for multiple input types

type PortsSource

type PortsSource []string

Jump to

Keyboard shortcuts

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