Documentation
¶
Index ¶
- func DeleteProject(name string) error
- func DependencyOrder(cf *ComposeFile) ([]string, error)
- func ProjectName(composeFile string) string
- func SaveProject(p *ProjectState) error
- type CommandOrArgs
- type ComposeFile
- type DependsOn
- type DownOptions
- type Environment
- type LogsOptions
- type Network
- type Orchestrator
- func (o *Orchestrator) Down(ctx context.Context, opts DownOptions) error
- func (o *Orchestrator) Logs(ctx context.Context, opts LogsOptions) error
- func (o *Orchestrator) Ps(ctx context.Context, opts PsOptions) ([]ServiceStatus, error)
- func (o *Orchestrator) Restart(ctx context.Context, opts RestartOptions) error
- func (o *Orchestrator) Up(ctx context.Context, opts UpOptions) error
- type ProjectState
- type PsOptions
- type RestartOptions
- type Service
- type ServiceState
- type ServiceStatus
- type StringOrSlice
- type UpOptions
- type Volume
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteProject ¶
func DependencyOrder ¶
func DependencyOrder(cf *ComposeFile) ([]string, error)
DependencyOrder returns service names in startup order (dependencies first). Uses Kahn's algorithm for topological sort.
func ProjectName ¶
ProjectName derives the project name from the compose file's directory.
func SaveProject ¶
func SaveProject(p *ProjectState) error
Types ¶
type CommandOrArgs ¶
type CommandOrArgs []string
CommandOrArgs handles both string and []string forms for command/entrypoint.
command: "echo hello" → ["echo", "hello"] command: ["echo", "hello"] → ["echo", "hello"]
func (*CommandOrArgs) UnmarshalYAML ¶
func (c *CommandOrArgs) UnmarshalYAML(value *yaml.Node) error
type ComposeFile ¶
type ComposeFile struct {
Services map[string]Service `yaml:"services"`
Networks map[string]Network `yaml:"networks,omitempty"`
Volumes map[string]Volume `yaml:"volumes,omitempty"`
}
ComposeFile represents a parsed docker-compose.yml.
type DependsOn ¶
type DependsOn []string
DependsOn handles both list and map forms.
depends_on: [db, redis]
depends_on:
db:
condition: service_started
type DownOptions ¶
DownOptions configures the down command.
type Environment ¶
Environment handles both map and list forms.
environment:
FOO: bar → {"FOO": "bar"}
environment:
- FOO=bar → {"FOO": "bar"}
- BAZ → {"BAZ": ""} (inherit from host)
func (*Environment) UnmarshalYAML ¶
func (e *Environment) UnmarshalYAML(value *yaml.Node) error
type LogsOptions ¶
type LogsOptions struct {
File string
Project string
Service string // empty = all services
Follow bool
}
LogsOptions configures the logs command.
type Network ¶
type Network struct {
Driver string `yaml:"driver,omitempty"`
External bool `yaml:"external,omitempty"`
}
Network represents a top-level network definition.
type Orchestrator ¶
type Orchestrator struct {
// contains filtered or unexported fields
}
Orchestrator manages compose project lifecycle.
func NewOrchestrator ¶
func NewOrchestrator(eng *engine.Engine) *Orchestrator
func (*Orchestrator) Down ¶
func (o *Orchestrator) Down(ctx context.Context, opts DownOptions) error
Down stops and removes all services, then cleans up networks/volumes.
func (*Orchestrator) Logs ¶
func (o *Orchestrator) Logs(ctx context.Context, opts LogsOptions) error
Logs shows logs for one or all services.
func (*Orchestrator) Ps ¶
func (o *Orchestrator) Ps(ctx context.Context, opts PsOptions) ([]ServiceStatus, error)
Ps returns the status of all services in the project.
func (*Orchestrator) Restart ¶
func (o *Orchestrator) Restart(ctx context.Context, opts RestartOptions) error
Restart stops and starts a service (or all services).
type ProjectState ¶
type ProjectState struct {
Name string `json:"name"`
Dir string `json:"dir"`
File string `json:"file"`
Services map[string]ServiceState `json:"services"`
Networks []string `json:"networks,omitempty"`
Volumes []string `json:"volumes,omitempty"`
}
ProjectState is the persisted state of a compose project.
func LoadProject ¶
func LoadProject(name string) (*ProjectState, error)
type RestartOptions ¶
RestartOptions configures the restart command.
type Service ¶
type Service struct {
Image string `yaml:"image"`
ContainerName string `yaml:"container_name,omitempty"`
Command CommandOrArgs `yaml:"command,omitempty"`
Entrypoint CommandOrArgs `yaml:"entrypoint,omitempty"`
Ports []string `yaml:"ports,omitempty"`
Volumes []string `yaml:"volumes,omitempty"`
Environment Environment `yaml:"environment,omitempty"`
EnvFile StringOrSlice `yaml:"env_file,omitempty"`
DependsOn DependsOn `yaml:"depends_on,omitempty"`
Networks StringOrSlice `yaml:"networks,omitempty"`
Restart string `yaml:"restart,omitempty"`
WorkingDir string `yaml:"working_dir,omitempty"`
Hostname string `yaml:"hostname,omitempty"`
Memory string `yaml:"mem_limit,omitempty"`
CPUs string `yaml:"cpus,omitempty"`
Labels map[string]string `yaml:"labels,omitempty"`
}
Service represents a single service in a compose file.
type ServiceState ¶
type ServiceState struct {
Service string `json:"service"`
ContainerID string `json:"container_id"`
Image string `json:"image"`
Status string `json:"status"` // running, stopped, created
}
ServiceState tracks a running service's container within a project.
type ServiceStatus ¶
type ServiceStatus struct {
Service string `json:"service"`
Container string `json:"container"`
Image string `json:"image"`
Status string `json:"status"`
}
ServiceStatus is used for ps output.
type StringOrSlice ¶
type StringOrSlice []string
StringOrSlice handles fields that accept both a single string and a list.
env_file: .env env_file: - .env - .env.local
func (*StringOrSlice) UnmarshalYAML ¶
func (s *StringOrSlice) UnmarshalYAML(value *yaml.Node) error