compose

package
v0.0.0-...-bd1a880 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package compose provides functionality for Docker Compose operations

Package compose provides functionality for Docker Compose operations

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SanitizeProjectName

func SanitizeProjectName(name string) string

SanitizeProjectName removes potentially invalid characters for a Docker project name

Types

type ComposeService

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

ComposeService implements the Service interface

func (*ComposeService) Convert

func (s *ComposeService) Convert(ctx context.Context, composeFile *models.ComposeFile, options ConvertOptions) (*ConvertResult, error)

Convert converts a Docker Compose file to Docker API objects

func (*ComposeService) Down

func (s *ComposeService) Down(ctx context.Context, composeFile *models.ComposeFile, options models.RemoveOptions) error

Down removes a Docker Compose deployment

func (*ComposeService) Events

func (s *ComposeService) Events(ctx context.Context, composeFile *models.ComposeFile, options EventOptions) (<-chan DeploymentEvent, <-chan error)

Events gets events from services in a Docker Compose deployment

func (*ComposeService) Logs

func (s *ComposeService) Logs(ctx context.Context, composeFile *models.ComposeFile, options LogOptions) (io.ReadCloser, error)

Logs gets logs from services in a Docker Compose deployment

func (*ComposeService) Parse

func (s *ComposeService) Parse(ctx context.Context, reader io.Reader, options models.ParseOptions) (*models.ComposeFile, error)

Parse parses a Docker Compose file

func (*ComposeService) Ps

func (s *ComposeService) Ps(ctx context.Context, composeFile *models.ComposeFile, options PsOptions) (*DeploymentStatus, error)

Ps lists containers in a Docker Compose deployment

func (*ComposeService) Restart

func (s *ComposeService) Restart(ctx context.Context, composeFile *models.ComposeFile, options models.RestartOptions) error

Restart restarts services in a Docker Compose deployment

func (*ComposeService) Start

func (s *ComposeService) Start(ctx context.Context, composeFile *models.ComposeFile, options models.StartOptions) error

Start starts services in a Docker Compose deployment

func (*ComposeService) Stop

func (s *ComposeService) Stop(ctx context.Context, composeFile *models.ComposeFile, options models.StopOptions) error

Stop stops services in a Docker Compose deployment

func (*ComposeService) Up

func (s *ComposeService) Up(ctx context.Context, composeFile *models.ComposeFile, options models.DeployOptions) error

Up deploys a Docker Compose file

type ComposeServiceOptions

type ComposeServiceOptions struct {
	DockerClient   *client.Client
	Orchestrator   interfaces.ComposeOrchestrator // Use interface
	NetworkService networkSvc.Service
	VolumeService  volumeSvc.Service
	Logger         *logrus.Logger
	StatusTracker  interfaces.ComposeStatusTracker // Use interface type
}

ComposeServiceOptions defines options for creating a Docker Compose service

type ConvertOptions

type ConvertOptions struct {
	ProjectName string
	Format      string
	Logger      *logrus.Logger
}

ConvertOptions defines options for converting a Docker Compose file

type ConvertResult

type ConvertResult struct {
	Services map[string]*ServiceConfig
	Networks map[string]*NetworkConfig
	Volumes  map[string]*VolumeConfig
}

ConvertResult contains the result of converting a Docker Compose file

type DeploymentEvent

type DeploymentEvent struct {
	Type        string
	Action      string
	ServiceName string
	ContainerID string
	Time        time.Time
	Message     string
	Attributes  map[string]string
}

DeploymentEvent represents an event from a Docker Compose deployment

type DeploymentStatus

type DeploymentStatus struct {
	ProjectName string
	Services    map[string]*ServiceStatus
	StartTime   time.Time
	IsRunning   bool
}

DeploymentStatus contains information about a Docker Compose deployment

type EventOptions

type EventOptions struct {
	ProjectName string
	Services    []string
	Follow      bool
	Since       time.Time
	Until       time.Time
	Logger      *logrus.Logger
}

EventOptions defines options for getting events

type LogOptions

type LogOptions struct {
	ProjectName string
	Services    []string
	Follow      bool
	Tail        int
	Since       time.Time
	Until       time.Time
	Timestamps  bool
	Logger      *logrus.Logger
}

LogOptions defines options for getting logs

type NetworkConfig

type NetworkConfig struct {
	Name     string
	Driver   string
	Options  map[string]string
	IPAM     *network.IPAM
	Internal bool
	Labels   map[string]string
}

NetworkConfig contains Docker API configuration for a network

type ParseOptions

type ParseOptions struct {
	EnvFiles            []string
	Environment         map[string]string
	WorkingDir          string
	ResolveImageDigests bool
	Logger              *logrus.Logger
}

ParseOptions defines options for parsing a Docker Compose file

type Parser

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

Parser handles parsing and validation of Docker Compose files

func NewParser

func NewParser(logger *logrus.Logger) *Parser

NewParser creates a new Parser

func (*Parser) Parse

func (p *Parser) Parse(ctx context.Context,
	reader io.Reader,
	options models.ParseOptions) (*models.ComposeFile, error)

Parse reads and parses a Docker Compose configuration from an io.Reader using compose-go

type Port

type Port struct {
	HostIP        string
	HostPort      string
	ContainerPort string
	Protocol      string
}

Port represents a port mapping

type PsOptions

type PsOptions struct {
	ProjectName string
	Services    []string
	All         bool
	Logger      *logrus.Logger
}

PsOptions defines options for listing containers

type Service

type Service interface {
	// Parse parses a Docker Compose file
	Parse(ctx context.Context, reader io.Reader, options models.ParseOptions) (*models.ComposeFile, error) // Use models.ParseOptions

	// Up deploys a Docker Compose file
	Up(ctx context.Context, composeFile *models.ComposeFile, options models.DeployOptions) error // Use models options

	// Down removes a Docker Compose deployment
	Down(ctx context.Context, composeFile *models.ComposeFile, options models.RemoveOptions) error // Use models options

	// Start starts services in a Docker Compose deployment
	Start(ctx context.Context, composeFile *models.ComposeFile, options models.StartOptions) error // Use models options

	// Stop stops services in a Docker Compose deployment
	Stop(ctx context.Context, composeFile *models.ComposeFile, options models.StopOptions) error // Use models options

	// Restart restarts services in a Docker Compose deployment
	Restart(ctx context.Context, composeFile *models.ComposeFile, options models.RestartOptions) error // Use models options

	// Ps lists containers in a Docker Compose deployment
	Ps(ctx context.Context, composeFile *models.ComposeFile, options PsOptions) (*DeploymentStatus, error)

	// Logs gets logs from services in a Docker Compose deployment
	Logs(ctx context.Context, composeFile *models.ComposeFile, options LogOptions) (io.ReadCloser, error)

	// Events gets events from services in a Docker Compose deployment
	Events(ctx context.Context, composeFile *models.ComposeFile, options EventOptions) (<-chan DeploymentEvent, <-chan error)

	// Convert converts a Docker Compose file to Docker API objects
	Convert(ctx context.Context, composeFile *models.ComposeFile, options ConvertOptions) (*ConvertResult, error)
}

Service provides a high-level API for Docker Compose operations

func NewComposeService

func NewComposeService(options ComposeServiceOptions) (Service, error)

NewComposeService creates a new Docker Compose service

type ServiceConfig

type ServiceConfig struct {
	ContainerConfig  *container.Config
	HostConfig       *container.HostConfig
	NetworkingConfig *network.NetworkingConfig
}

ServiceConfig contains Docker API configuration for a service

type ServiceStatus

type ServiceStatus struct {
	Name          string
	ContainerID   string
	ContainerName string
	Image         string
	Status        string
	Health        string
	Ports         []Port
	StartTime     time.Time
	IsRunning     bool
}

ServiceStatus contains information about a service in a Docker Compose deployment

type VolumeConfig

type VolumeConfig struct {
	Name       string
	Driver     string
	DriverOpts map[string]string
	Labels     map[string]string
}

VolumeConfig contains Docker API configuration for a volume

Directories

Path Synopsis
Package converter provides functionality for converting Docker Compose structures to Docker API structures
Package converter provides functionality for converting Docker Compose structures to Docker API structures
Package orchestrator provides functionality for orchestrating Docker Compose deployments
Package orchestrator provides functionality for orchestrating Docker Compose deployments
Package resources provides functionality for managing Docker Compose resources
Package resources provides functionality for managing Docker Compose resources
Package status provides functionality for monitoring Docker Compose service status
Package status provides functionality for monitoring Docker Compose service status
Package types provides common structures for Docker Compose functionality
Package types provides common structures for Docker Compose functionality

Jump to

Keyboard shortcuts

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