compose

package
v0.24.7 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package compose provides Docker Compose project processing functionality

Package compose provides Docker Compose file parsing and handling

Package compose provides Docker Compose project processing functionality

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindEnvFiles added in v0.21.0

func FindEnvFiles(serviceName, workingDir string) []string

FindEnvFiles discovers environment files for a service in a working directory.

func HasNamingConflict added in v0.21.0

func HasNamingConflict(repo Repository, unitName, unitType string) bool

HasNamingConflict checks for potential naming conflicts with existing units.

func IsExternal added in v0.21.0

func IsExternal(external interface{}) bool

IsExternal checks if a resource configuration indicates it's externally managed.

func NameResolver added in v0.9.0

func NameResolver(explicitName, defaultName string) string

NameResolver returns the explicit name if provided, otherwise returns the default name.

func ParseComposeFile

func ParseComposeFile(path string) (*types.Project, error)

ParseComposeFile parses a Docker Compose file at the specified path.

func ParseComposeFileWithLogger added in v0.21.0

func ParseComposeFileWithLogger(path string, logger log.Logger) (*types.Project, error)

ParseComposeFileWithLogger parses a Docker Compose file at the specified path with a provided logger.

func Prefix added in v0.21.0

func Prefix(projectName, resourceName string) string

Prefix creates a prefixed resource name using project name and resource name. No sanitization is performed; the projectName must already be valid according to the service name regex: ^[a-zA-Z0-9][a-zA-Z0-9_.-]*$.

func ReadProjects

func ReadProjects(path string) ([]*types.Project, error)

ReadProjects reads all Docker Compose projects from a directory path.

func ReadProjectsWithLogger added in v0.21.0

func ReadProjectsWithLogger(path string, logger log.Logger) ([]*types.Project, error)

ReadProjectsWithLogger reads all Docker Compose projects from a directory path with a provided logger.

func SanitizeProjectName added in v0.24.7

func SanitizeProjectName(name string) string

SanitizeProjectName sanitizes a project name to make it safe for use in resource names. Project names come from compose files and may contain spaces and other invalid characters. This replaces invalid characters (spaces) with hyphens, while preserving underscores which are valid.

Types

type FileSystem added in v0.21.0

type FileSystem interface {
	GetUnitFilePath(name, unitType string) string
	HasUnitChanged(unitPath, content string) bool
	WriteUnitFile(unitPath, content string) error
	GetContentHash(content string) string
}

FileSystem defines the interface for file system operations.

type Repository added in v0.21.0

type Repository interface {
	FindAll() ([]repository.Unit, error)
	Create(unit *repository.Unit) (*repository.Unit, error)
	Delete(id string) error
}

Repository defines the interface for unit repository operations.

type SpecConverter added in v0.22.0

type SpecConverter struct {
	// contains filtered or unexported fields
}

SpecConverter converts Docker Compose projects to service.Spec models.

func NewSpecConverter added in v0.22.0

func NewSpecConverter(workingDir string) *SpecConverter

NewSpecConverter creates a new SpecConverter.

func (*SpecConverter) ConvertProject added in v0.22.0

func (sc *SpecConverter) ConvertProject(project *types.Project) ([]service.Spec, error)

ConvertProject converts a Docker Compose project to a list of service specs. It normalizes multi-container setups into multiple Spec instances, handling services, volumes, networks, and build configurations.

type SpecProcessor added in v0.22.0

type SpecProcessor struct {
	// contains filtered or unexported fields
}

SpecProcessor processes Docker Compose projects into service specs. It wraps SpecConverter to provide the standard Process interface.

func NewSpecProcessor added in v0.22.0

func NewSpecProcessor(workingDir string) *SpecProcessor

NewSpecProcessor creates a new SpecProcessor with the given working directory.

func (*SpecProcessor) Process added in v0.22.0

func (p *SpecProcessor) Process(_ context.Context, project *types.Project) ([]service.Spec, error)

Process converts a Docker Compose project to service specs.

type SystemdManager added in v0.21.0

type SystemdManager interface {
	RestartChangedUnits(units []systemd.UnitChange, projectDependencyGraphs map[string]*dependency.ServiceDependencyGraph) error
	ReloadSystemd() error
	StopUnit(name, unitType string) error
}

SystemdManager defines the interface for systemd operations.

Jump to

Keyboard shortcuts

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