Documentation
¶
Overview ¶
Package deploy performs rolling container deployments across one or more Docker hosts, using docker.Client instances for the underlying operations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInProgress = errors.New("a deployment for this container is already in progress")
ErrInProgress means a deployment for the same container is already running. Overlapping deploys are rejected rather than serialized to avoid interleaving rename/stop/run steps on the same container.
var ErrIncompatible = errors.New("image is incompatible with the running container")
ErrIncompatible means the requested image could not be applied to the existing container (bad/missing image, or create/start failed with the preserved spec). The previous container is restored when possible.
var ErrNotRunning = errors.New("container is not running on any configured host")
ErrNotRunning means the named container was not found running on any configured Docker host.
ErrUnavailable means a Docker host/operation failed for infrastructural reasons (list/inspect/rename/stop, connectivity, etc.).
Functions ¶
func HTTPStatus ¶
HTTPStatus maps a Deploy error to an HTTP status for the webhook. Prefer Result.HTTPStatus when a Result is available (handles partial 207).
func PublicError ¶
PublicError returns a short, non-sensitive error label suitable for HTTP responses and CI logs. Detailed causes stay in server logs only.
Types ¶
type Client ¶
type Client interface {
Host() string
ListRunningNames(ctx context.Context) ([]string, error)
Pull(ctx context.Context, image string) error
Inspect(ctx context.Context, container string) (*docker.ContainerSpec, error)
Rename(ctx context.Context, oldName, newName string) error
Stop(ctx context.Context, container string) error
Run(ctx context.Context, spec *docker.ContainerSpec) (string, error)
Start(ctx context.Context, container string) error
Remove(ctx context.Context, container string) error
}
Client is the subset of *docker.Client the deployer needs. It is satisfied by *docker.Client and can be faked in tests.
type HostResult ¶
type HostResult struct {
// Index is the position of this host in the service's configured client
// list (0-based). Prefer this over Host when returning data to callers.
Index int
Host string
Err error
}
HostResult is the outcome of a deployment on a single host.
type Result ¶
type Result struct {
Container string
Image string
Hosts []HostResult
}
Result aggregates per-host outcomes for one Deploy call.
func (Result) HTTPStatus ¶
HTTPStatus picks the webhook status for this result. Partial updates → 207; otherwise delegates to HTTPStatus(err) / 200.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service performs rolling deployments across a fixed set of Docker hosts.
func NewService ¶
NewService returns a Service that can deploy to the given clients.
func (*Service) Deploy ¶
Deploy replaces container with a new instance running image, but only on hosts where that container is already running. Hosts without a matching running container are skipped. Selected hosts are updated one at a time; the first failure stops the roll so a bad image does not take down the rest of the matched fleet. Hosts already updated are left on the new image (partial success → Result.Partial() / HTTP 207).