Documentation
¶
Index ¶
- func LoadEnvFile(path string) (map[string]string, error)
- func LoadEnvFiles(paths []string) (map[string]string, error)
- func MergeEnv(maps ...map[string]string) map[string]string
- func ParseEnvSlice(env []string) map[string]string
- func SubstituteEnv(input string, env map[string]string) string
- func SubstituteEnvInMap(m map[string]string, env map[string]string) map[string]string
- func SubstituteEnvInSlice(s []string, env map[string]string) []string
- func ToEnvSlice(m map[string]string) []string
- func Validate(file *ComposeFile) error
- type BuildConfig
- type ComposeFile
- type Config
- type ConfigManager
- type DeployConfig
- type DeployResources
- type DeployRestartPolicy
- type DevelopConfig
- type Engine
- func (e *Engine) Build() error
- func (e *Engine) Config() (string, error)
- func (e *Engine) Create() error
- func (e *Engine) Down() error
- func (e *Engine) KillServices(signal string, services []string) error
- func (e *Engine) Load(path string) error
- func (e *Engine) Logs(tail int) (map[string]string, error)
- func (e *Engine) PauseServices(services []string) error
- func (e *Engine) PrintConfigSubset(services, volumes, networks bool)
- func (e *Engine) ProjectImages() ([]common.ImageInfo, error)
- func (e *Engine) Ps() ([]common.ContainerInfo, error)
- func (e *Engine) Publish(cfg *PublishConfig) error
- func (e *Engine) Pull() error
- func (e *Engine) Restart() error
- func (e *Engine) RestartServices(services []string) error
- func (e *Engine) Start() error
- func (e *Engine) StartServices(services []string) error
- func (e *Engine) Stop() error
- func (e *Engine) StopServices(services []string) error
- func (e *Engine) Top(services []string) error
- func (e *Engine) UnpauseServices(services []string) error
- func (e *Engine) Up() error
- type HealthcheckConfig
- type LoggingConfig
- type Network
- type OCIDescriptor
- type OCIManifest
- type PublishConfig
- type ResourceLimits
- type Secret
- type SecretManager
- type Service
- type ServiceWatcher
- type ValidationError
- type ValidationErrors
- type Volume
- type WatchAction
- type WatchManager
- type WatchRule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadEnvFile ¶
LoadEnvFile loads environment variables from a file. Format: KEY=VALUE (one per line). Lines starting with # are comments. Empty lines are ignored. Quotes around values are stripped.
func LoadEnvFiles ¶
LoadEnvFiles loads multiple env files and merges them. Later files override earlier ones.
func ParseEnvSlice ¶
ParseEnvSlice converts a slice of "KEY=VALUE" strings to a map.
func SubstituteEnv ¶
SubstituteEnv replaces ${VAR}, ${VAR:-default}, ${VAR:+alt}, and $VAR in the input string with values from the provided environment map. If a variable is not found in the map, it falls back to os.Getenv.
func SubstituteEnvInMap ¶
SubstituteEnvInMap applies SubstituteEnv to all values in a map.
func SubstituteEnvInSlice ¶
SubstituteEnvInSlice applies SubstituteEnv to all strings in a slice.
func ToEnvSlice ¶
ToEnvSlice converts a map to a slice of "KEY=VALUE" strings.
Types ¶
type BuildConfig ¶
type BuildConfig struct {
Context string `yaml:"context"`
Dokifile string `yaml:"dokifile,omitempty"`
Dockerfile string `yaml:"dockerfile,omitempty"`
Args map[string]string `yaml:"args,omitempty"`
Labels map[string]string `yaml:"labels,omitempty"`
Target string `yaml:"target,omitempty"`
Network string `yaml:"network,omitempty"`
CacheFrom []string `yaml:"cache_from,omitempty"`
}
BuildConfig defines build settings for a service.
type ComposeFile ¶
type ComposeFile struct {
Version string `yaml:"version,omitempty"`
Name string `yaml:"name,omitempty"`
Services map[string]*Service `yaml:"services"`
Networks map[string]*Network `yaml:"networks,omitempty"`
Volumes map[string]*Volume `yaml:"volumes,omitempty"`
Configs map[string]*Config `yaml:"configs,omitempty"`
Secrets map[string]*Secret `yaml:"secrets,omitempty"`
Include []string `yaml:"include,omitempty"`
}
ComposeFile represents a docki-compose file (doki.yml).
type Config ¶
type Config struct {
File string `yaml:"file,omitempty"`
External bool `yaml:"external,omitempty"`
}
Config represents a compose config.
type ConfigManager ¶
type ConfigManager struct {
// contains filtered or unexported fields
}
ConfigManager manages compose configs.
func NewConfigManager ¶
func NewConfigManager(projectDir string, configs map[string]*Config) *ConfigManager
NewConfigManager creates a new config manager.
func (*ConfigManager) GetConfigPath ¶
func (cm *ConfigManager) GetConfigPath(name string) (string, error)
GetConfigPath returns the path to a config file.
func (*ConfigManager) MountAllConfigs ¶
func (cm *ConfigManager) MountAllConfigs(svcConfigs []string, destDir string) error
MountAllConfigs mounts all configs for a service.
func (*ConfigManager) MountConfig ¶
func (cm *ConfigManager) MountConfig(name, destDir string) error
MountConfig mounts a config into a container directory.
type DeployConfig ¶
type DeployConfig struct {
Replicas int `yaml:"replicas,omitempty"`
Resources *DeployResources `yaml:"resources,omitempty"`
RestartPolicy *DeployRestartPolicy `yaml:"restart_policy,omitempty"`
}
DeployConfig defines deployment settings.
type DeployResources ¶
type DeployResources struct {
Limits *ResourceLimits `yaml:"limits,omitempty"`
Reservations *ResourceLimits `yaml:"reservations,omitempty"`
}
DeployResources defines resource limits.
type DeployRestartPolicy ¶
type DeployRestartPolicy struct {
Condition string `yaml:"condition,omitempty"`
Delay string `yaml:"delay,omitempty"`
MaxAttempts int `yaml:"max_attempts,omitempty"`
}
DeployRestartPolicy defines restart policy for deployments.
type DevelopConfig ¶ added in v0.10.0
type DevelopConfig struct {
Watch []WatchRule `yaml:"watch,omitempty" json:"watch,omitempty"`
}
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is the compose engine.
func (*Engine) Create ¶ added in v0.9.3
Create creates the project containers without starting them.
func (*Engine) Down ¶
Down stops and removes all services, networks, and volumes created by this compose project. External networks/volumes are preserved.
func (*Engine) KillServices ¶ added in v0.9.3
KillServices sends a signal to the specified services.
func (*Engine) PauseServices ¶ added in v0.9.3
PauseServices suspends the specified services.
func (*Engine) PrintConfigSubset ¶ added in v0.9.3
PrintConfigSubset prints the names of services, volumes, or networks declared in the compose file.
func (*Engine) ProjectImages ¶ added in v0.9.3
ProjectImages returns the images associated with this compose project.
func (*Engine) Ps ¶
func (e *Engine) Ps() ([]common.ContainerInfo, error)
Ps lists running services.
func (*Engine) Publish ¶ added in v0.10.0
func (e *Engine) Publish(cfg *PublishConfig) error
func (*Engine) RestartServices ¶ added in v0.9.3
RestartServices restarts only the specified services.
func (*Engine) Start ¶ added in v0.9.3
Start starts stopped services. For containers that exited, recreates them via Up.
func (*Engine) StartServices ¶ added in v0.9.3
StartServices starts only the specified services.
func (*Engine) StopServices ¶ added in v0.9.3
StopServices stops only the specified services.
func (*Engine) UnpauseServices ¶ added in v0.9.3
UnpauseServices resumes the specified paused services.
type HealthcheckConfig ¶
type HealthcheckConfig struct {
Test interface{} `yaml:"test"`
Interval string `yaml:"interval,omitempty"`
Timeout string `yaml:"timeout,omitempty"`
Retries int `yaml:"retries,omitempty"`
StartPeriod string `yaml:"start_period,omitempty"`
StartInterval string `yaml:"start_interval,omitempty"`
Disable bool `yaml:"disable,omitempty"`
}
HealthcheckConfig defines healthcheck for a service.
type LoggingConfig ¶ added in v0.9.3
type LoggingConfig struct {
Driver string `yaml:"driver,omitempty"`
Options map[string]string `yaml:"options,omitempty"`
}
LoggingConfig defines logging settings.
type Network ¶
type Network struct {
Driver string `yaml:"driver,omitempty"`
External bool `yaml:"external,omitempty"`
Name string `yaml:"name,omitempty"`
Internal bool `yaml:"internal,omitempty"`
EnableIPv6 bool `yaml:"enable_ipv6,omitempty"`
}
Network represents a compose network.
type OCIDescriptor ¶ added in v0.10.0
type OCIManifest ¶ added in v0.10.0
type OCIManifest struct {
SchemaVersion int `json:"schemaVersion"`
MediaType string `json:"mediaType"`
Config OCIDescriptor `json:"config"`
Layers []OCIDescriptor `json:"layers"`
Annotations map[string]string `json:"annotations,omitempty"`
}
type PublishConfig ¶ added in v0.10.0
type ResourceLimits ¶
type ResourceLimits struct {
CPUs string `yaml:"cpus,omitempty"`
Memory string `yaml:"memory,omitempty"`
}
ResourceLimits defines resource limits.
type Secret ¶
type Secret struct {
File string `yaml:"file,omitempty"`
External bool `yaml:"external,omitempty"`
}
Secret represents a compose secret.
type SecretManager ¶
type SecretManager struct {
// contains filtered or unexported fields
}
SecretManager manages compose secrets.
func NewSecretManager ¶
func NewSecretManager(projectDir string, secrets map[string]*Secret) *SecretManager
NewSecretManager creates a new secret manager.
func (*SecretManager) GetSecretPath ¶
func (sm *SecretManager) GetSecretPath(name string) (string, error)
GetSecretPath returns the path to a secret file.
func (*SecretManager) MountAllSecrets ¶
func (sm *SecretManager) MountAllSecrets(svcSecrets []string, destDir string) error
MountAllSecrets mounts all secrets for a service.
func (*SecretManager) MountSecret ¶
func (sm *SecretManager) MountSecret(name, destDir string) error
MountSecret mounts a secret into a container directory.
type Service ¶
type Service struct {
Image string `yaml:"image,omitempty"`
Build *BuildConfig `yaml:"build,omitempty"`
Command interface{} `yaml:"command,omitempty"`
Entrypoint interface{} `yaml:"entrypoint,omitempty"`
Environment interface{} `yaml:"environment,omitempty"`
EnvFile interface{} `yaml:"env_file,omitempty"`
Ports interface{} `yaml:"ports,omitempty"`
Expose []string `yaml:"expose,omitempty"`
Volumes interface{} `yaml:"volumes,omitempty"`
Networks interface{} `yaml:"networks,omitempty"`
NetworkMode string `yaml:"network_mode,omitempty"`
DependsOn interface{} `yaml:"depends_on,omitempty"`
Restart string `yaml:"restart,omitempty"`
Labels interface{} `yaml:"labels,omitempty"`
WorkingDir string `yaml:"working_dir,omitempty"`
User string `yaml:"user,omitempty"`
Hostname string `yaml:"hostname,omitempty"`
Domainname string `yaml:"domainname,omitempty"`
Tty bool `yaml:"tty,omitempty"`
StdinOpen bool `yaml:"stdin_open,omitempty"`
Privileged bool `yaml:"privileged,omitempty"`
ReadOnly bool `yaml:"read_only,omitempty"`
Init bool `yaml:"init,omitempty"`
DNS interface{} `yaml:"dns,omitempty"`
DNSSearch interface{} `yaml:"dns_search,omitempty"`
DNSOpt interface{} `yaml:"dns_opt,omitempty"`
ExtraHosts interface{} `yaml:"extra_hosts,omitempty"`
CapAdd []string `yaml:"cap_add,omitempty"`
CapDrop []string `yaml:"cap_drop,omitempty"`
SecurityOpt []string `yaml:"security_opt,omitempty"`
Sysctls map[string]string `yaml:"sysctls,omitempty"`
Healthcheck *HealthcheckConfig `yaml:"healthcheck,omitempty"`
StopSignal string `yaml:"stop_signal,omitempty"`
StopGracePeriod string `yaml:"stop_grace_period,omitempty"`
Deploy *DeployConfig `yaml:"deploy,omitempty"`
Profile string `yaml:"profile,omitempty"`
Profiles []string `yaml:"profiles,omitempty"`
Extends interface{} `yaml:"extends,omitempty"`
Secrets []string `yaml:"secrets,omitempty"`
Configs []string `yaml:"configs,omitempty"`
ContainerName string `yaml:"container_name,omitempty"`
ShmSize string `yaml:"shm_size,omitempty"`
PidsLimit int64 `yaml:"pids_limit,omitempty"`
OomKillDisable bool `yaml:"oom_kill_disable,omitempty"`
OomScoreAdj int `yaml:"oom_score_adj,omitempty"`
MacAddress string `yaml:"mac_address,omitempty"`
Logging *LoggingConfig `yaml:"logging,omitempty"`
Ulimits map[string]interface{} `yaml:"ulimits,omitempty"`
Tmpfs interface{} `yaml:"tmpfs,omitempty"`
BlkioConfig map[string]interface{} `yaml:"blkio_config,omitempty"`
Devices []string `yaml:"devices,omitempty"`
Platform string `yaml:"platform,omitempty"`
Runtime string `yaml:"runtime,omitempty"`
Scale int `yaml:"scale,omitempty"`
}
Service represents a service (container) in the compose file.
type ServiceWatcher ¶ added in v0.10.0
type ServiceWatcher struct {
// contains filtered or unexported fields
}
type ValidationError ¶
ValidationError represents a compose file validation error.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
type ValidationErrors ¶
type ValidationErrors []*ValidationError
ValidationErrors is a list of validation errors.
func (ValidationErrors) Error ¶
func (ve ValidationErrors) Error() string
type Volume ¶
type Volume struct {
Driver string `yaml:"driver,omitempty"`
External bool `yaml:"external,omitempty"`
Name string `yaml:"name,omitempty"`
DriverOpts map[string]string `yaml:"driver_opts,omitempty"`
}
Volume represents a compose volume.
type WatchAction ¶ added in v0.10.0
type WatchAction string
const ( WatchSync WatchAction = "sync" WatchRebuild WatchAction = "rebuild" WatchSyncRestart WatchAction = "sync+restart" )
type WatchManager ¶ added in v0.10.0
type WatchManager struct {
// contains filtered or unexported fields
}
func NewWatchManager ¶ added in v0.10.0
func NewWatchManager(engine *Engine, logger *slog.Logger) *WatchManager
func (*WatchManager) Active ¶ added in v0.10.0
func (wm *WatchManager) Active() []string
func (*WatchManager) Start ¶ added in v0.10.0
func (wm *WatchManager) Start(service string, rules []WatchRule) error
func (*WatchManager) Stop ¶ added in v0.10.0
func (wm *WatchManager) Stop(service string) error
func (*WatchManager) StopAll ¶ added in v0.10.0
func (wm *WatchManager) StopAll()