DCW (Docker Compose Wrapper)

A powerful wrapper for Docker Compose with advanced features

View on GitHub

Code Structure

The Docker Compose Wrapper is organized into several key components:

Directory Structure

.
├── cmd/
│   └── compose-wrapper/    # Main application entry point
├── internal/
│   ├── app/               # Core application logic
│   ├── chart/             # Chart management
│   ├── template/          # Template processing
│   └── values/            # Values management
├── pkg/
│   └── utils/             # Shared utilities
└── docs/                  # Documentation

Key Components

Command Line Interface (cmd/compose-wrapper/)

The main entry point for the application, handling command-line arguments and routing to appropriate handlers.

// main.go
func main() {
    // Parse command line arguments
    // Initialize application
    // Execute commands
}

Core Application Logic (internal/app/)

Contains the main business logic for:

Key files:

Chart Management (internal/chart/)

Handles chart-related operations:

// chart.go
type Chart struct {
    Name       string
    Version    string
    Templates  []Template
    Values     map[string]interface{}
}

Template Processing (internal/template/)

Manages template rendering and processing:

// template.go
type Template struct {
    Name     string
    Content  string
    Values   map[string]interface{}
}

Values Management (internal/values/)

Handles configuration values:

// values.go
type Values struct {
    Global    map[string]interface{}
    Services  map[string]Service
}

Key Interfaces

Service Interface

type Service interface {
    Start() error
    Stop() error
    Restart() error
    Scale(replicas int) error
    RollingUpdate(config RollingUpdateConfig) error
}

Chart Interface

type Chart interface {
    Load() error
    Validate() error
    Render() (string, error)
    GetValues() map[string]interface{}
}

Error Handling

The application uses a consistent error handling approach:

Testing

The codebase includes: