Documentation
¶
Index ¶
- func ComposeFile() (string, error)
- func ComposeFileArgs(files []string) []string
- func ComposeProject(ctx context.Context, projectName string, filenames []string, profiles []string, ...) (*types.Project, error)
- func DeployOneShotService(ctx context.Context, input DeployOneShotServiceInput) error
- func DeployProject(ctx context.Context, input DeployProjectInput) error
- func DeployService(ctx context.Context, input DeployServiceInput) error
- func EnvFileArgs(files []string) []string
- func IsCronService(service *types.ServiceConfig) bool
- func IsOneShotService(service *types.ServiceConfig) bool
- func OrderServices(ctx context.Context, input DeployProjectInput) ([]string, error)
- func ParseEveryInterval(schedule string) (time.Duration, bool)
- func RemoveMissingServices(ctx context.Context, input DeployProjectInput, orderedServices []string) error
- func ResolvePullPolicy(cliPullPolicy string, cliBuild bool, service *types.ServiceConfig) (string, bool, error)
- func RunService(ctx context.Context, input RunServiceInput) error
- func ServiceReplicas(input DeployServiceInput, service *types.ServiceConfig) int
- func SpawnCronTask(ctx context.Context, input SpawnCronTaskInput) error
- type CommandExecutor
- type ComposeContainersInput
- type ContainerNameTemplateData
- type CronConfig
- type CronDefaults
- type CronNotifier
- type CronNotifyConfig
- type CronProject
- type CronScheduler
- type CronService
- type CronWebhookPayload
- type DeployOneShotServiceInput
- type DeployProjectInput
- type DeployServiceInput
- type DockerClient
- func (d *DockerClient) Close() error
- func (d *DockerClient) ContainerExecAttach(ctx context.Context, execID string, config container.ExecAttachOptions) (types.HijackedResponse, error)
- func (d *DockerClient) ContainerExecCreate(ctx context.Context, containerID string, config container.ExecOptions) (container.ExecCreateResponse, error)
- func (d *DockerClient) ContainerExecInspect(ctx context.Context, execID string) (container.ExecInspect, error)
- func (d *DockerClient) ContainerExecStart(ctx context.Context, execID string, config container.ExecStartOptions) error
- func (d *DockerClient) ContainerInspect(ctx context.Context, containerID string) (container.InspectResponse, error)
- func (d *DockerClient) ContainerList(ctx context.Context, options container.ListOptions) ([]container.Summary, error)
- func (d *DockerClient) ContainerLogs(ctx context.Context, containerID string, options container.LogsOptions) (io.ReadCloser, error)
- func (d *DockerClient) ContainerRemove(ctx context.Context, containerID string, options container.RemoveOptions) error
- func (d *DockerClient) ContainerRename(ctx context.Context, containerID, newName string) error
- func (d *DockerClient) ContainerStart(ctx context.Context, containerID string, options container.StartOptions) error
- func (d *DockerClient) ContainerStop(ctx context.Context, containerID string, options container.StopOptions) error
- func (d *DockerClient) ContainerTerminate(ctx context.Context, containerID string, timeoutSeconds int) error
- func (d *DockerClient) CopyToContainer(ctx context.Context, containerID, dstPath string, content io.Reader, ...) error
- func (d *DockerClient) Events(ctx context.Context, options events.ListOptions) (<-chan events.Message, <-chan error)
- func (d *DockerClient) ImageInspect(ctx context.Context, imageID string) (image.InspectResponse, error)
- type DockerClientInterface
- type DotOrchestrateConfig
- type ErrorWithOutput
- type ExecCommandInput
- type ExecCommandResponse
- type ExecResult
- type ExecTask
- type ListRunExecutionsInput
- type MidnightPinnedSchedule
- type OneShotServiceInfo
- type RenameContainersToConventionInput
- type RollingUpdateInput
- type RollingUpdateOutput
- type RunContainerHookInput
- type RunContainerHooksInput
- type RunContainerScriptInput
- type RunExecution
- type RunServiceInput
- type ScaleDownContainersInput
- type ScaleUpContainersInput
- type ScriptTemplateData
- type ServiceConfigStatus
- type ServiceConfigStatusInput
- type ShouldSkipScaleDownServiceInput
- type ShouldSkipServiceInput
- type SpawnCronTaskInput
- type SpawnerFunc
- type WaitForHealthcheckInput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComposeFile ¶
ComposeFile gets the compose file from the current directory or the specified directory
func ComposeFileArgs ¶
ComposeFileArgs returns the command-line arguments for specifying one or more compose files to docker compose (e.g., ["-f", "a.yml", "-f", "b.yml"]).
func ComposeProject ¶
func ComposeProject(ctx context.Context, projectName string, filenames []string, profiles []string, envFiles []string) (*types.Project, error)
ComposeProject reads the compose files specified by the filenames and returns the compose types.Project
func DeployOneShotService ¶
func DeployOneShotService(ctx context.Context, input DeployOneShotServiceInput) error
DeployOneShotService runs a one-shot service (restart: "no") to completion. It runs `docker compose run [--rm] --no-deps <service>`, blocks until exit, and returns an error on non-zero exit code.
func DeployProject ¶
func DeployProject(ctx context.Context, input DeployProjectInput) error
DeployProject deploys a project
func DeployService ¶
func DeployService(ctx context.Context, input DeployServiceInput) error
DeployService deploys a single service
func EnvFileArgs ¶
EnvFileArgs returns the command-line arguments for specifying one or more env files to docker compose (e.g., ["--env-file", "a.env", "--env-file", "b.env"]).
func IsCronService ¶
func IsCronService(service *types.ServiceConfig) bool
IsCronService returns true if the service has an x-cron extension configured
func IsOneShotService ¶
func IsOneShotService(service *types.ServiceConfig) bool
IsOneShotService returns true if the service is a one-shot service (restart: "no")
func OrderServices ¶
func OrderServices(ctx context.Context, input DeployProjectInput) ([]string, error)
OrderServices orders the services in the project in dependency order deploy each service in the project 1. one-shot services (restart: "no") with no dependencies are deployed first 2. then the web service if it exists and has no dependencies 3. then everything else in dependency order if the web service has dependencies, skip it and deploy all services in dependency order
func ParseEveryInterval ¶
ParseEveryInterval parses an @every expression and returns the interval duration. Returns zero duration and false if the expression is not an @every expression.
func RemoveMissingServices ¶
func RemoveMissingServices(ctx context.Context, input DeployProjectInput, orderedServices []string) error
func ResolvePullPolicy ¶
func ResolvePullPolicy(cliPullPolicy string, cliBuild bool, service *types.ServiceConfig) (string, bool, error)
ResolvePullPolicy resolves the effective pull policy and build flag from CLI flags and compose spec. CLI flags take precedence. If neither pull policy is set, defaults to "missing". Compose spec "if_not_present" is mapped to "missing". Compose spec "build" sets pull to "never" and build to true (requires a build section). The --build CLI flag enables building for services that have a build section.
func RunService ¶
func RunService(ctx context.Context, input RunServiceInput) error
RunService runs a one-shot service on demand. It validates the service exists and is a one-shot service, runs deploy hooks, and executes the service with labels for execution tracking.
func ServiceReplicas ¶
func ServiceReplicas(input DeployServiceInput, service *types.ServiceConfig) int
ServiceReplicas returns the number of containers that should be running get the number of containers that should be running
from the `input.Replicas` field if specified or the `service.[service-name].deploy.replicas` field in the compose file or the `service.[service-name].scale` field in the compose file or 1 if none of the above are specified
func SpawnCronTask ¶
func SpawnCronTask(ctx context.Context, input SpawnCronTaskInput) error
SpawnCronTask spawns a one-shot container for a cron task. It attaches metadata labels to the container for the notifier to use. If no-overlap is enabled, it checks for running containers first. The container is spawned in a fire-and-forget manner.
Types ¶
type CommandExecutor ¶
type CommandExecutor func(ctx context.Context, input ExecCommandInput) (ExecCommandResponse, error)
CommandExecutor is a function that executes a command
type ComposeContainersInput ¶
type ComposeContainersInput struct {
// Client is the Docker client to use. If nil, a new one will be created.
Client DockerClientInterface
// ProjectName is the name of the project
ProjectName string
// ServiceName is the name of the service
ServiceName string
// Status is the status of the containers to return
Status string
}
ComposeContainersInput is the input for the ComposeContainers function
type ContainerNameTemplateData ¶
type ContainerNameTemplateData struct {
// ProjectName is the name of the project
ProjectName string
// ServiceName is the name of the service
ServiceName string
// InstanceID is the instance ID
InstanceID int
}
ContainerNameTemplateData is the data structure for container name templates
type CronConfig ¶
type CronConfig struct {
// Schedule is the cron expression or @every interval
Schedule string
// Timezone is the IANA timezone name
Timezone string
// Timeout is the maximum duration for the cron task
Timeout time.Duration
// NoOverlap prevents concurrent execution of the same cron task
NoOverlap bool
// Notify is the notification configuration
Notify *CronNotifyConfig
}
CronConfig represents the parsed x-cron configuration for a service
func ParseCronConfig ¶
func ParseCronConfig(service *types.ServiceConfig, defaults *CronDefaults, cliTimezone string) (*CronConfig, error)
ParseCronConfig parses x-cron from a service's extensions
type CronDefaults ¶
type CronDefaults struct {
// Timezone is the default timezone for all cron services in the project
Timezone string
// Notify is the default notification configuration
Notify *CronNotifyConfig
}
CronDefaults represents project-level cron defaults from x-cron-defaults
func ParseCronDefaults ¶
func ParseCronDefaults(extensions map[string]interface{}) (*CronDefaults, error)
ParseCronDefaults parses x-cron-defaults from project-level extensions
type CronNotifier ¶
type CronNotifier struct {
// contains filtered or unexported fields
}
CronNotifier listens for Docker container events and sends webhook notifications for completed cron tasks based on container labels.
func NewCronNotifier ¶
func NewCronNotifier(client DockerClientInterface, logger *command.ZerologUi) *CronNotifier
NewCronNotifier creates a new notifier that watches Docker events
func (*CronNotifier) RecoverOrphanedContainers ¶
func (n *CronNotifier) RecoverOrphanedContainers(ctx context.Context) error
RecoverOrphanedContainers finds cron containers that exited while the notifier was not running and processes their notifications.
func (*CronNotifier) RecoverOrphans ¶
func (n *CronNotifier) RecoverOrphans(ctx context.Context) error
RecoverOrphans is an alias for RecoverOrphanedContainers
type CronNotifyConfig ¶
type CronNotifyConfig struct {
// URL is the webhook endpoint
URL string
// On determines when to send notifications: "success", "failure", or "always"
On string
// IncludeOutput includes stdout/stderr in the webhook payload
IncludeOutput bool
}
CronNotifyConfig represents webhook notification settings
type CronProject ¶
type CronProject struct {
// Name is the project name
Name string
// ComposeFiles is the list of compose file paths
ComposeFiles []string
// EnvFiles is the list of env file paths
EnvFiles []string
// WorkingDirectory is the project working directory
WorkingDirectory string
// Defaults is the project-level cron defaults
Defaults *CronDefaults
// Services is the list of cron-scheduled services
Services []CronService
}
CronProject represents a project with cron-scheduled services
func LoadSingleProject ¶
func LoadSingleProject(ctx context.Context, composeFiles []string, envFiles []string, projectName string, cliTimezone string) (*CronProject, error)
LoadSingleProject loads a single project from compose files
func ScanProjects ¶
ScanProjects scans a directory for Docker Compose projects with cron-scheduled services. Each subdirectory is treated as a potential project. Project compose files are resolved in this order:
- .docker-orchestrate YAML file (explicit config)
- .env file with COMPOSE_FILE/COMPOSE_PROJECT_NAME variables
- Default: docker-compose.yml or compose.yml
type CronScheduler ¶
type CronScheduler struct {
// contains filtered or unexported fields
}
CronScheduler manages cron job scheduling for one or more projects
func NewCronScheduler ¶
func NewCronScheduler(projects []CronProject, spawner SpawnerFunc, logger *command.ZerologUi) (*CronScheduler, error)
NewCronScheduler creates a new cron scheduler with the given projects and spawner function
func (*CronScheduler) Entries ¶
func (s *CronScheduler) Entries() int
Entries returns the number of scheduled entries
func (*CronScheduler) Reload ¶
func (s *CronScheduler) Reload(projects []CronProject) error
Reload updates the scheduler with new project configurations. It removes jobs that are no longer present, adds new jobs, and updates jobs whose configuration has changed.
func (*CronScheduler) RunConfigReloader ¶
func (s *CronScheduler) RunConfigReloader(ctx context.Context, reloadInterval time.Duration, loadProjects func() ([]CronProject, error))
RunConfigReloader starts a goroutine that periodically re-reads project configurations and reloads the scheduler. It also listens for SIGHUP to trigger an immediate reload.
func (*CronScheduler) Stop ¶
func (s *CronScheduler) Stop() context.Context
Stop halts the cron scheduler
type CronService ¶
type CronService struct {
// Name is the service name
Name string
// Config is the parsed cron configuration
Config *CronConfig
// Service is the compose service configuration
Service *types.ServiceConfig
}
CronService represents a service with cron scheduling
type CronWebhookPayload ¶
type CronWebhookPayload struct {
Project string `json:"project"`
Service string `json:"service"`
Schedule string `json:"schedule"`
Status string `json:"status"`
ExitCode int `json:"exit_code"`
DurationSeconds float64 `json:"duration_seconds"`
TriggeredAt string `json:"triggered_at"`
CompletedAt string `json:"completed_at"`
ContainerName string `json:"container_name"`
Stdout string `json:"stdout,omitempty"`
Stderr string `json:"stderr,omitempty"`
}
CronWebhookPayload is the JSON payload sent to webhook endpoints
type DeployOneShotServiceInput ¶
type DeployOneShotServiceInput struct {
// Build is whether to build images before running
Build bool
// ComposeFiles is the list of paths to the compose files
ComposeFiles []string
// ContainerName is the custom container name (empty = docker default)
ContainerName string
// EnvFiles is the list of paths to the env files
EnvFiles []string
// Executor is the command executor to use
Executor CommandExecutor
// Labels is the list of additional labels to attach to the container (e.g. "key=value")
Labels []string
// Logger is the logger to use
Logger *command.ZerologUi
// NoRemove when true skips the --rm flag so the container persists after exit
NoRemove bool
// ProjectName is the name of the project
ProjectName string
// PullPolicy is the pull policy override from the CLI flag
PullPolicy string
// Service is the service configuration
Service *types.ServiceConfig
// ServiceName is the name of the service
ServiceName string
// StreamOutput streams stdout and stderr to the terminal
StreamOutput bool
}
DeployOneShotServiceInput is the input for the DeployOneShotService function
type DeployProjectInput ¶
type DeployProjectInput struct {
// Build is whether to build images before deploying
Build bool
// Client is the Docker client to use
Client DockerClientInterface
// ComposeFiles is the list of paths to the compose files
ComposeFiles []string
// ContainerNameTemplate is the Go template for container names
ContainerNameTemplate string
// EnvFiles is the list of paths to the env files
EnvFiles []string
// EnvVars is the parsed environment variables from env files
EnvVars map[string]string
// Executor is the command executor to use
Executor CommandExecutor
// Force forces deploy even if service config is unchanged
Force bool
// Logger is the logger to use
Logger *command.ZerologUi
// Project is the project configuration
Project *types.Project
// ProjectName is the name of the project
ProjectName string
// PullPolicy is the pull policy override from the CLI flag (always, missing, never)
PullPolicy string
// SkipDatabases is whether to skip deploying databases
SkipDatabases bool
}
DeployProjectInput is the input for the DeployProject function
type DeployServiceInput ¶
type DeployServiceInput struct {
// Build is whether to build images before deploying
Build bool
// Client is the Docker client to use
Client DockerClientInterface
// ComposeFiles is the list of paths to the compose files
ComposeFiles []string
// ContainerNameTemplate is the Go template for container names
ContainerNameTemplate string
// EnvFiles is the list of paths to the env files
EnvFiles []string
// EnvVars is the parsed environment variables from env files
EnvVars map[string]string
// Executor is the command executor to use
Executor CommandExecutor
// Force forces deploy even if service config is unchanged
Force bool
// Logger is the logger to use
Logger *command.ZerologUi
// Project is the project configuration
Project *types.Project
// ProjectName is the name of the project
ProjectName string
// PullPolicy is the pull policy override from the CLI flag (always, missing, never)
PullPolicy string
// Replicas is the number of replicas to deploy
Replicas int
// ServiceName is the name of the service
ServiceName string
// SkipDatabases is whether to skip deploying databases
SkipDatabases bool
}
DeployServiceInput is the input for the DeployService function
type DockerClient ¶
type DockerClient struct {
// contains filtered or unexported fields
}
DockerClient is a wrapper around the Docker client
func (*DockerClient) ContainerExecAttach ¶
func (d *DockerClient) ContainerExecAttach(ctx context.Context, execID string, config container.ExecAttachOptions) (types.HijackedResponse, error)
ContainerExecAttach attaches to an exec instance
func (*DockerClient) ContainerExecCreate ¶
func (d *DockerClient) ContainerExecCreate(ctx context.Context, containerID string, config container.ExecOptions) (container.ExecCreateResponse, error)
ContainerExecCreate creates an exec instance in a container
func (*DockerClient) ContainerExecInspect ¶
func (d *DockerClient) ContainerExecInspect(ctx context.Context, execID string) (container.ExecInspect, error)
ContainerExecInspect inspects an exec instance
func (*DockerClient) ContainerExecStart ¶
func (d *DockerClient) ContainerExecStart(ctx context.Context, execID string, config container.ExecStartOptions) error
ContainerExecStart starts an exec instance
func (*DockerClient) ContainerInspect ¶
func (d *DockerClient) ContainerInspect(ctx context.Context, containerID string) (container.InspectResponse, error)
ContainerInspect inspects a container
func (*DockerClient) ContainerList ¶
func (d *DockerClient) ContainerList(ctx context.Context, options container.ListOptions) ([]container.Summary, error)
ContainerList lists containers
func (*DockerClient) ContainerLogs ¶
func (d *DockerClient) ContainerLogs(ctx context.Context, containerID string, options container.LogsOptions) (io.ReadCloser, error)
ContainerLogs returns logs from a container
func (*DockerClient) ContainerRemove ¶
func (d *DockerClient) ContainerRemove(ctx context.Context, containerID string, options container.RemoveOptions) error
ContainerRemove removes a container
func (*DockerClient) ContainerRename ¶
func (d *DockerClient) ContainerRename(ctx context.Context, containerID, newName string) error
ContainerRename renames a container
func (*DockerClient) ContainerStart ¶
func (d *DockerClient) ContainerStart(ctx context.Context, containerID string, options container.StartOptions) error
ContainerStart starts a container
func (*DockerClient) ContainerStop ¶
func (d *DockerClient) ContainerStop(ctx context.Context, containerID string, options container.StopOptions) error
ContainerStop stops a container
func (*DockerClient) ContainerTerminate ¶
func (d *DockerClient) ContainerTerminate(ctx context.Context, containerID string, timeoutSeconds int) error
ContainerTerminate terminates a container
func (*DockerClient) CopyToContainer ¶
func (d *DockerClient) CopyToContainer(ctx context.Context, containerID, dstPath string, content io.Reader, options container.CopyToContainerOptions) error
CopyToContainer copies content to a container
func (*DockerClient) Events ¶
func (d *DockerClient) Events(ctx context.Context, options events.ListOptions) (<-chan events.Message, <-chan error)
Events returns a stream of Docker events
func (*DockerClient) ImageInspect ¶
func (d *DockerClient) ImageInspect(ctx context.Context, imageID string) (image.InspectResponse, error)
ImageInspect inspects an image
type DockerClientInterface ¶
type DockerClientInterface interface {
Close() error
ContainerExecCreate(ctx context.Context, containerID string, config container.ExecOptions) (container.ExecCreateResponse, error)
ContainerExecStart(ctx context.Context, execID string, config container.ExecStartOptions) error
ContainerExecAttach(ctx context.Context, execID string, config container.ExecAttachOptions) (types.HijackedResponse, error)
ContainerExecInspect(ctx context.Context, execID string) (container.ExecInspect, error)
ContainerInspect(ctx context.Context, containerID string) (container.InspectResponse, error)
ContainerList(ctx context.Context, options container.ListOptions) ([]container.Summary, error)
ImageInspect(ctx context.Context, imageID string) (image.InspectResponse, error)
ContainerRemove(ctx context.Context, containerID string, options container.RemoveOptions) error
ContainerRename(ctx context.Context, containerID, newName string) error
ContainerStart(ctx context.Context, containerID string, options container.StartOptions) error
ContainerStop(ctx context.Context, containerID string, options container.StopOptions) error
ContainerLogs(ctx context.Context, containerID string, options container.LogsOptions) (io.ReadCloser, error)
ContainerTerminate(ctx context.Context, containerID string, timeoutSeconds int) error
CopyToContainer(ctx context.Context, containerID, dstPath string, content io.Reader, options container.CopyToContainerOptions) error
Events(ctx context.Context, options events.ListOptions) (<-chan events.Message, <-chan error)
}
DockerClientInterface is an interface for the Docker client
func NewDockerClient ¶
func NewDockerClient() (DockerClientInterface, error)
NewDockerClient returns a new Docker client instance
type DotOrchestrateConfig ¶
type DotOrchestrateConfig struct {
ComposeFiles []string `yaml:"compose-files"`
EnvFiles []string `yaml:"env-files"`
}
DotOrchestrateConfig represents the .docker-orchestrate configuration file
type ErrorWithOutput ¶
ErrorWithOutput is an error with output
func (*ErrorWithOutput) Error ¶
func (e *ErrorWithOutput) Error() string
Error returns the error message
type ExecCommandInput ¶
type ExecCommandInput struct {
// Command is the command to execute
Command string
// Args are the arguments to pass to the command
Args []string
// DisableStdioBuffer disables the stdio buffer
DisableStdioBuffer bool
// Env is the environment variables to pass to the command
Env map[string]string
// Stdin is the stdin of the command
Stdin io.Reader
// StreamStdio prints stdout and stderr directly to os.Stdout/err as
// the command runs
StreamStdio bool
// StreamStdout prints stdout directly to os.Stdout as the command runs.
StreamStdout bool
// StreamStderr prints stderr directly to os.Stderr as the command runs.
StreamStderr bool
// StdoutWriter is the writer to write stdout to
StdoutWriter io.Writer
// StderrWriter is the writer to write stderr to
StderrWriter io.Writer
// Sudo runs the command with sudo -n -u root
Sudo bool
// WorkingDirectory is the working directory to run the command in
WorkingDirectory string
// Detached starts the command and returns immediately without waiting
// for it to complete. The process is forked synchronously (guaranteed
// to be running when the function returns) but runs independently
// in the background.
Detached bool
}
ExecCommandInput is the input for the ExecCommand function
type ExecCommandResponse ¶
type ExecCommandResponse struct {
// Stdout is the stdout of the command
Stdout string
// Stderr is the stderr of the command
Stderr string
// ExitCode is the exit code of the command
ExitCode int
// Cancelled is whether the command was cancelled
Cancelled bool
}
ExecCommandResponse is the response for the ExecCommand function
func ExecCommand ¶
func ExecCommand(ctx context.Context, input ExecCommandInput) (ExecCommandResponse, error)
ExecCommand executes a command on the local host with the given context
func (ExecCommandResponse) StderrBytes ¶
func (ecr ExecCommandResponse) StderrBytes() []byte
StderrBytes returns the trimmed stderr of the command as bytes
func (ExecCommandResponse) StderrContents ¶
func (ecr ExecCommandResponse) StderrContents() string
StderrContents returns the trimmed stderr of the command
func (ExecCommandResponse) StdoutBytes ¶
func (ecr ExecCommandResponse) StdoutBytes() []byte
StdoutBytes returns the trimmed stdout of the command as bytes
func (ExecCommandResponse) StdoutContents ¶
func (ecr ExecCommandResponse) StdoutContents() string
StdoutContents returns the trimmed stdout of the command
type ExecResult ¶
ExecResult contains the result of executing a command
type ExecTask ¶
type ExecTask struct {
// Command is the command to execute.
//
// Any arguments must be given via Args
Command string
// Args are the arguments to pass to the command.
Args []string
// Shell run the command in a bash shell.
// Note that the system must have `bash` installed in the PATH or in /bin/bash
Shell bool
// Env is a list of environment variables to add to the current environment,
// these are used to override any existing environment variables.
Env []string
// Cwd is the working directory for the command
Cwd string
// Stdin connect a reader to stdin for the command
// being executed.
Stdin io.Reader
// PrintCommand prints the command before executing
PrintCommand bool
// StreamStdio prints stdout and stderr directly to os.Stdout/err as
// the command runs.
StreamStdio bool
// DisableStdioBuffer prevents any output from being saved in the
// ExecResult, which is useful for when the result is very large, or
// when you want to stream the output to another writer exclusively.
DisableStdioBuffer bool
// StdOutWriter when set will receive a copy of stdout from the command
StdOutWriter io.Writer
// StdErrWriter when set will receive a copy of stderr from the command
StdErrWriter io.Writer
// Detached starts the command synchronously (ensuring the OS process is
// forked) but does not wait for it to complete. The process runs
// independently in the background. A goroutine is spawned to reap
// the child process via Wait.
Detached bool
}
ExecTask describes a command to execute
type ListRunExecutionsInput ¶
type ListRunExecutionsInput struct {
// Client is the Docker client
Client DockerClientInterface
// ProjectName filters by project name (empty = all projects)
ProjectName string
}
ListRunExecutionsInput is the input for the ListRunExecutions function
type MidnightPinnedSchedule ¶
type MidnightPinnedSchedule struct {
// Interval is the duration between runs
Interval time.Duration
// Location is the timezone for midnight calculation
Location *time.Location
}
MidnightPinnedSchedule implements cron.Schedule for @every intervals pinned to midnight in the configured timezone rather than process start time.
func NewMidnightPinnedSchedule ¶
func NewMidnightPinnedSchedule(interval time.Duration, loc *time.Location) (*MidnightPinnedSchedule, error)
NewMidnightPinnedSchedule creates a new MidnightPinnedSchedule. Returns an error if the interval is invalid.
func (*MidnightPinnedSchedule) Next ¶
func (s *MidnightPinnedSchedule) Next(t time.Time) time.Time
Next returns the next activation time for the midnight-pinned schedule. The schedule fires at regular intervals from midnight in the configured timezone. At day boundaries, the schedule wraps to the next day's midnight.
type OneShotServiceInfo ¶
type OneShotServiceInfo struct {
// Name is the service name
Name string
// Command is the service command as a string
Command string
}
OneShotServiceInfo contains information about a one-shot service
func ListOneShotServices ¶
func ListOneShotServices(project *composetypes.Project) []OneShotServiceInfo
ListOneShotServices returns a list of one-shot services in the project
type RenameContainersToConventionInput ¶
type RenameContainersToConventionInput struct {
// Client is the Docker client to use. If nil, a new one will be created.
Client DockerClientInterface
// Containers is the list of containers to rename
Containers []container.Summary
// ProjectName is the name of the project
ProjectName string
// ServiceName is the name of the service
ServiceName string
// NameTemplate is the Go template for container names
NameTemplate string
}
type RollingUpdateInput ¶
type RollingUpdateInput struct {
// Build is whether to build images before deploying
Build bool
// Client is the Docker client to use. If nil, a new one will be created.
Client DockerClientInterface
// ComposeFiles is the list of paths to the compose files
ComposeFiles []string
// ContainersToUpdate is the list of containers to update
ContainersToUpdate []container.Summary
// EnvFiles is the list of paths to the env files
EnvFiles []string
// EnvVars is the parsed environment variables from env files
EnvVars map[string]string
// CurrentReplicas is the current number of replicas
CurrentReplicas int
// Delay is the delay between batches
Delay time.Duration
// DesiredReplicas is the target number of replicas
DesiredReplicas int
// Executor is the command executor to use. If nil, ExecCommand will be used.
Executor CommandExecutor
// FailureAction is the action to take on failure (pause or empty)
FailureAction string
// HealthcheckCommand is the command to run for health checks
HealthcheckCommand string
// HealthcheckWait is the duration to wait before considering a container without a Docker healthcheck as healthy
HealthcheckWait time.Duration
// WaitAfterHealthy is the duration to wait after a container becomes healthy before proceeding
WaitAfterHealthy time.Duration
// Logger is the logger to use
Logger *command.ZerologUi
// MaxFailureRatio is the maximum allowed failure ratio
MaxFailureRatio float32
// Monitor is the health check monitoring duration
Monitor time.Duration
// Order is the update order strategy (start-first or stop-first)
Order string
// Parallelism is the number of containers to update simultaneously
Parallelism int
// ProjectDir is the project directory
ProjectDir string
// ProjectName is the name of the project
ProjectName string
// PullPolicy is the pull policy to pass to docker compose (always, missing, never)
PullPolicy string
// RollbackConfig is the optional rollback configuration. Used when FailureAction is "rollback".
RollbackConfig *types.UpdateConfig
// ServiceName is the name of the service
ServiceName string
// Sleeper is the function to use for sleeping. If nil, time.Sleep will be used.
Sleeper func(time.Duration)
// PreStopHostCommand is the command to run before stopping a container (on host)
PreStopHostCommand string
// PreStopHostCommandDetached indicates if the pre-stop host command should run detached
PreStopHostCommandDetached bool
// PreStopCommand is the command to run inside the container before stopping
PreStopCommand string
// PreStopHooks are the compose spec pre_stop hooks to run inside the container before stopping
PreStopHooks []types.ServiceHook
// PostStopHostCommand is the command to run after stopping a container
PostStopHostCommand string
// PostStopHostCommandDetached indicates if the post-stop command should run detached
PostStopHostCommandDetached bool
// StopTimeout is the timeout in seconds for stopping containers (from stop_grace_period)
StopTimeout int
// TickerCh is an optional channel to use for ticking. If nil, time.NewTicker will be used.
TickerCh <-chan time.Time
}
RollingUpdateInput contains the parameters for rolling update
type RollingUpdateOutput ¶
type RollingUpdateOutput struct {
// Failures is the number of failures
Failures int
// TotalUpdates is the total number of updates
TotalUpdates int
}
RollingUpdateOutput is the output of the rollingUpdateContainers function
type RunContainerHookInput ¶
type RunContainerHookInput struct {
// Client is the Docker client to use
Client DockerClientInterface
// ContainerID is the ID of the container
ContainerID string
// Hook is the compose spec service hook to execute
Hook composeTypes.ServiceHook
// ServiceName is the name of the service
ServiceName string
}
RunContainerHookInput is the input for the runContainerHook function
type RunContainerHooksInput ¶
type RunContainerHooksInput struct {
// Client is the Docker client to use
Client DockerClientInterface
// ContainerID is the ID of the container
ContainerID string
// Hooks is the list of compose spec service hooks to execute
Hooks []composeTypes.ServiceHook
// ServiceName is the name of the service
ServiceName string
}
RunContainerHooksInput is the input for the runContainerHooks function
type RunContainerScriptInput ¶
type RunContainerScriptInput struct {
// Client is the Docker client to use
Client DockerClientInterface
// ContainerID is the ID of the container
ContainerID string
// Env is the environment variables to pass to the container exec
Env map[string]string
// Script is the script content to execute
Script string
// ScriptPath is the path inside the container where the script will be written
ScriptPath string
// ServiceName is the name of the service
ServiceName string
}
RunContainerScriptInput is the input for the runContainerScript function
type RunExecution ¶
type RunExecution struct {
// ContainerName is the name of the container
ContainerName string
// Service is the service name
Service string
// Status is the container status (e.g. "running", "exited")
Status string
// ExitCode is the exit code (-1 if still running)
ExitCode int
// TriggeredAt is when the execution was triggered
TriggeredAt string
}
RunExecution contains information about an executed one-shot service
func ListRunExecutions ¶
func ListRunExecutions(ctx context.Context, input ListRunExecutionsInput) ([]RunExecution, error)
ListRunExecutions returns a list of past and running one-shot service executions
type RunServiceInput ¶
type RunServiceInput struct {
// Build is whether to build images before running
Build bool
// Client is the Docker client
Client DockerClientInterface
// ComposeFiles is the list of paths to the compose files
ComposeFiles []string
// Detach runs the service in the background
Detach bool
// EnvFiles is the list of paths to the env files
EnvFiles []string
// EnvVars is the parsed environment variables
EnvVars map[string]string
// Executor is the command executor to use
Executor CommandExecutor
// Logger is the logger to use
Logger *command.ZerologUi
// Project is the parsed compose project
Project *composetypes.Project
// ProjectName is the name of the project
ProjectName string
// PullPolicy is the pull policy override from the CLI flag
PullPolicy string
// ServiceName is the name of the service
ServiceName string
}
RunServiceInput is the input for the RunService function
type ScaleDownContainersInput ¶
type ScaleDownContainersInput struct {
// Client is the Docker client to use. If nil, a new one will be created.
Client DockerClientInterface
// ComposeFiles is the list of paths to the compose files
ComposeFiles []string
// CurrentContainers is the current list of containers
CurrentContainers []container.Summary
// EnvFiles is the list of paths to the env files
EnvFiles []string
// EnvVars is the parsed environment variables from env files
EnvVars map[string]string
// CurrentReplicas is the current number of containers
CurrentReplicas int
// DesiredReplicas is the target number of replicas
DesiredReplicas int
// Executor is the command executor to use. If nil, ExecCommand will be used.
Executor CommandExecutor
// Logger is the logger to use
Logger *command.ZerologUi
// ProjectName is the name of the project
ProjectName string
// ServiceName is the name of the service
ServiceName string
// SkipDatabases is whether to skip interacting with databases
SkipDatabases bool
// PreStopHostCommand is the command to run before stopping a container (on host)
PreStopHostCommand string
// PreStopHostCommandDetached indicates if the pre-stop host command should run detached
PreStopHostCommandDetached bool
// PreStopCommand is the command to run inside the container before stopping
PreStopCommand string
// PreStopHooks are the compose spec pre_stop hooks to run inside the container before stopping
PreStopHooks []types.ServiceHook
// PostStopHostCommand is the command to run after stopping a container
PostStopHostCommand string
// PostStopHostCommandDetached indicates if the post-stop command should run detached
PostStopHostCommandDetached bool
// StopTimeout is the timeout in seconds for stopping containers (from stop_grace_period)
StopTimeout int
}
type ScaleUpContainersInput ¶
type ScaleUpContainersInput struct {
// Build is whether to build images before deploying
Build bool
// Client is the Docker client to use. If nil, a new one will be created.
Client DockerClientInterface
// ComposeFiles is the list of paths to the compose files
ComposeFiles []string
// CurrentReplicas is the current number of containers
CurrentReplicas int
// EnvFiles is the list of paths to the env files
EnvFiles []string
// EnvVars is the parsed environment variables from env files
EnvVars map[string]string
// Delay is the delay between batches
Delay time.Duration
// DesiredReplicas is the target number of replicas
DesiredReplicas int
// Executor is the command executor to use. If nil, ExecCommand will be used.
Executor CommandExecutor
// ExistingContainers is the list of existing containers to skip
ExistingContainers []container.Summary
// FailureAction is the action to take on failure (pause or empty)
FailureAction string
// HealthcheckCommand is the command to run for health checks
HealthcheckCommand string
// HealthcheckWait is the duration to wait before considering a container without a Docker healthcheck as healthy
HealthcheckWait time.Duration
// WaitAfterHealthy is the duration to wait after a container becomes healthy before proceeding
WaitAfterHealthy time.Duration
// Logger is the logger to use
Logger *command.ZerologUi
// MaxFailureRatio is the maximum allowed failure ratio
MaxFailureRatio float32
// Monitor is the health check monitoring duration
Monitor time.Duration
// Parallelism is the number of containers to update simultaneously
Parallelism int
// PostStartHooks are the compose spec post_start hooks to run inside the container after starting
PostStartHooks []types.ServiceHook
// ProjectDir is the project directory
ProjectDir string
// ProjectName is the name of the project
ProjectName string
// PullPolicy is the pull policy to pass to docker compose (always, missing, never)
PullPolicy string
// RollbackConfig is the optional rollback configuration. Used when FailureAction is "rollback".
RollbackConfig *types.UpdateConfig
// ServiceName is the name of the service
ServiceName string
// Sleeper is the function to use for sleeping. If nil, time.Sleep will be used.
Sleeper func(time.Duration)
// PreStopHostCommand is the command to run before stopping a container (on host)
PreStopHostCommand string
// PreStopHostCommandDetached indicates if the pre-stop host command should run detached
PreStopHostCommandDetached bool
// PreStopCommand is the command to run inside the container before stopping
PreStopCommand string
// PreStopHooks are the compose spec pre_stop hooks to run inside the container before stopping
PreStopHooks []types.ServiceHook
// PostStopHostCommand is the command to run after stopping a container
PostStopHostCommand string
// PostStopHostCommandDetached indicates if the post-stop command should run detached
PostStopHostCommandDetached bool
// StopTimeout is the timeout in seconds for stopping containers (from stop_grace_period)
StopTimeout int
// TickerCh is an optional channel to use for ticking. If nil, time.NewTicker will be used.
TickerCh <-chan time.Time
}
ScaleUpContainersInput is the input for the scaleUpContainers function
type ScriptTemplateData ¶
type ScriptTemplateData struct {
// ContainerID is the ID of the container
ContainerID string
// ContainerIP is the IP address of the container
ContainerIP string
// ContainerShortID is the short ID of the container
ContainerShortID string
// ProjectName is the name of the project
ProjectName string
// ServiceName is the name of the service
ServiceName string
}
ScriptTemplateData is the data structure for the healthcheck command template
type ServiceConfigStatus ¶
type ServiceConfigStatus int
ServiceConfigStatus represents the result of checking service configuration
const ( // ServiceConfigChanged means the service config has changed and a full deploy is needed ServiceConfigChanged ServiceConfigStatus = iota // ServiceConfigUnchanged means the service is identical and can be skipped entirely ServiceConfigUnchanged // ServiceReplicaOnlyChange means only the replica count differs; skip rolling update, only scale ServiceReplicaOnlyChange )
type ServiceConfigStatusInput ¶
type ServiceConfigStatusInput struct {
// BuildImage is whether images will actually be built for this service
BuildImage bool
// Client is the Docker client to use
Client DockerClientInterface
// ComposeFiles is the list of compose files (for pull command)
ComposeFiles []string
// EnvFiles is the list of env files (for pull command)
EnvFiles []string
// Executor is the command executor to use (for pulling images)
Executor CommandExecutor
// Force forces deploy even if service config is unchanged
Force bool
// Logger is the logger to use
Logger *command.ZerologUi
// ProjectName is the name of the project
ProjectName string
// PullPolicy is the resolved pull policy for this service
PullPolicy string
// Replicas is the desired number of replicas
Replicas int
// Service is the service configuration
Service *types.ServiceConfig
// ServiceName is the name of the service
ServiceName string
}
ServiceConfigStatusInput is the input for the serviceConfigStatus function
type ShouldSkipScaleDownServiceInput ¶
type ShouldSkipScaleDownServiceInput struct {
// Container is the container to check
Container container.Summary
// ServiceName is the name of the service
ServiceName string
// ShouldSkipDatabases is whether to skip interacting with databases
ShouldSkipDatabases bool
// Logger is the logger to use
Logger *command.ZerologUi
}
ShouldSkipScaleDownServiceInput is the input for the shouldSkipScaleDownService function
type ShouldSkipServiceInput ¶
type ShouldSkipServiceInput struct {
// Logger is the logger to use
Logger *command.ZerologUi
// Service is the service configuration
Service *types.ServiceConfig
// ShouldSkipDatabases is whether to skip deploying databases
ShouldSkipDatabases bool
// SilenceLogging is whether to silence logging
SilenceLogging bool
}
ShouldSkipServiceInput is the input for the shouldSkipService function
type SpawnCronTaskInput ¶
type SpawnCronTaskInput struct {
// Build is whether to build images before running
Build bool
// Executor is the command executor to use
Executor CommandExecutor
// Logger is the logger to use
Logger *command.ZerologUi
// Project is the cron project configuration
Project CronProject
// PullPolicy is the pull policy override from the CLI flag
PullPolicy string
// Service is the cron service configuration
Service CronService
}
SpawnCronTaskInput is the input for the SpawnCronTask function
type SpawnerFunc ¶
type SpawnerFunc func(ctx context.Context, project CronProject, service CronService) error
SpawnerFunc is the function signature for spawning cron tasks
type WaitForHealthcheckInput ¶
type WaitForHealthcheckInput struct {
// Client is the Docker client to use. If nil, a new one will be created.
Client DockerClientInterface
// ContainerID is the ID of the container to wait for
ContainerID string
// Executor is the command executor to use. If nil, ExecCommand will be used.
Executor CommandExecutor
// HealthcheckCommand is the command to run for health checks
HealthcheckCommand string
// Monitor is the health check monitoring duration
Monitor time.Duration
// ProjectName is the name of the project
ProjectName string
// ServiceName is the name of the service
ServiceName string
// TickerCh is an optional channel to use for ticking. If nil, time.NewTicker will be used.
TickerCh <-chan time.Time
// HealthcheckWait is the duration to wait before considering a container without a Docker healthcheck as healthy.
// The container must be continuously running for this duration. If it restarts, the timer resets.
HealthcheckWait time.Duration
}
WaitForDockerHealthCheckInput is the input for the waitForDockerHealthCheck function