compose

package
v0.21.1 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 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

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 LabelConverter added in v0.9.0

func LabelConverter(labels types.Labels) []string

LabelConverter converts compose-style labels to unit labels.

func NameResolver added in v0.9.0

func NameResolver(definedName, keyName string) string

NameResolver resolves resource names from compose configs.

func OptionsConverter added in v0.9.0

func OptionsConverter(opts map[string]string) []string

OptionsConverter converts driver options to unit options.

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 for consistency.

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.

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.

func NewFileSystemAdapter added in v0.21.0

func NewFileSystemAdapter(configProvider config.Provider) FileSystem

NewFileSystemAdapter creates a new filesystem adapter with config provider.

func NewFileSystemAdapterWithConfig added in v0.21.0

func NewFileSystemAdapterWithConfig(configProvider config.Provider) FileSystem

NewFileSystemAdapterWithConfig creates a new filesystem adapter with config provider. This is an alias for NewFileSystemAdapter to maintain backward compatibility.

type FileSystemAdapter added in v0.21.0

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

FileSystemAdapter adapts fs operations to our interface.

func (*FileSystemAdapter) GetContentHash added in v0.21.0

func (f *FileSystemAdapter) GetContentHash(content string) string

GetContentHash returns a hash of the content.

func (*FileSystemAdapter) GetUnitFilePath added in v0.21.0

func (f *FileSystemAdapter) GetUnitFilePath(name, unitType string) string

GetUnitFilePath returns the file path for a unit.

func (*FileSystemAdapter) HasUnitChanged added in v0.21.0

func (f *FileSystemAdapter) HasUnitChanged(unitPath, content string) bool

HasUnitChanged checks if a unit file has changed.

func (*FileSystemAdapter) WriteUnitFile added in v0.21.0

func (f *FileSystemAdapter) WriteUnitFile(unitPath, content string) error

WriteUnitFile writes a unit file to disk.

type Processor added in v0.21.0

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

Processor handles the conversion of Docker Compose projects to Podman systemd units.

func NewDefaultProcessor added in v0.21.0

func NewDefaultProcessor(force bool) *Processor

NewDefaultProcessor creates a new Processor with default real dependencies.

func NewProcessor added in v0.21.0

func NewProcessor(repo Repository, systemd SystemdManager, fs FileSystem, logger log.Logger, force bool) *Processor

NewProcessor creates a new Processor with the given dependencies.

func (*Processor) GetProcessedUnits added in v0.21.0

func (p *Processor) GetProcessedUnits() map[string]bool

GetProcessedUnits returns the map of processed units.

func (*Processor) ProcessProjects added in v0.21.0

func (p *Processor) ProcessProjects(projects []*types.Project, cleanup bool) error

ProcessProjects processes Docker Compose projects and converts them to Podman systemd units.

func (*Processor) WithExistingProcessedUnits added in v0.21.0

func (p *Processor) WithExistingProcessedUnits(existingUnits map[string]bool) *Processor

WithExistingProcessedUnits sets existing processed units for tracking across multiple calls.

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.

func NewRepositoryAdapter added in v0.21.0

func NewRepositoryAdapter(repo repository.Repository) Repository

NewRepositoryAdapter creates a new repository adapter.

type RepositoryAdapter added in v0.21.0

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

RepositoryAdapter adapts repository.Repository to our interface.

func (*RepositoryAdapter) Create added in v0.21.0

func (r *RepositoryAdapter) Create(unit *repository.Unit) (*repository.Unit, error)

Create creates a new unit in the repository.

func (*RepositoryAdapter) Delete added in v0.21.0

func (r *RepositoryAdapter) Delete(_ string) error

Delete removes a unit from the repository.

func (*RepositoryAdapter) FindAll added in v0.21.0

func (r *RepositoryAdapter) FindAll() ([]repository.Unit, error)

FindAll retrieves all units from the repository.

type SystemdAdapter added in v0.21.0

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

SystemdAdapter adapts systemd operations to our interface.

func (*SystemdAdapter) ReloadSystemd added in v0.21.0

func (s *SystemdAdapter) ReloadSystemd() error

ReloadSystemd reloads the systemd configuration.

func (*SystemdAdapter) RestartChangedUnits added in v0.21.0

func (s *SystemdAdapter) RestartChangedUnits(units []systemd.UnitChange, projectDependencyGraphs map[string]*dependency.ServiceDependencyGraph) error

RestartChangedUnits restarts units that have changed.

func (*SystemdAdapter) StopUnit added in v0.21.0

func (s *SystemdAdapter) StopUnit(name, unitType string) error

StopUnit stops a systemd unit.

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.

func NewSystemdAdapter added in v0.21.0

func NewSystemdAdapter(unitManager systemd.UnitManager, orchestrator systemd.Orchestrator) SystemdManager

NewSystemdAdapter creates a new systemd adapter with dependency injection.

Jump to

Keyboard shortcuts

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