Help us shape the future of Go! Take the 2026 Go Developer Survey

swarm

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package swarm is the Swarm orchestrator: it applies a compose project to a swarm as services, the way docker stack deploy does, and waits until they converged.

Index

Constants

View Source
const Name = "swarm"

Name is the value of the nemo-orchestrator parameter that selects Swarm.

Variables

This section is empty.

Functions

func New

New connects to the Docker of the target, which must be a manager of an active swarm.

Types

type Client

type Client struct {
	*docker.Client
}

Client is the Engine client of the Swarm orchestrator: the one every Docker has, and what only a swarm has, services, tasks, configs and secrets, one file per kind.

func (*Client) ConfigCreate

func (swarmClient *Client) ConfigCreate(ctx context.Context, spec *swarm.ConfigSpec) (string, error)

func (*Client) ConfigDelete

func (swarmClient *Client) ConfigDelete(ctx context.Context, config *swarm.Config) error

ConfigDelete removes the config. The error tells, with docker.IsInUse, that a service still uses it.

func (*Client) ConfigFind

func (swarmClient *Client) ConfigFind(ctx context.Context, name string) (*swarm.Config, error)

ConfigFind returns the config of that exact name, or nil.

func (*Client) ConfigList

func (swarmClient *Client) ConfigList(ctx context.Context, filters client.Filters) ([]swarm.Config, error)

func (*Client) ConfigUpdate

func (swarmClient *Client) ConfigUpdate(ctx context.Context, existing *swarm.Config, spec *swarm.ConfigSpec) error

ConfigUpdate replaces the labels of an existing config: Swarm changes nothing else of a config, its data least of all.

func (*Client) SecretCreate

func (swarmClient *Client) SecretCreate(ctx context.Context, spec *swarm.SecretSpec) (string, error)

func (*Client) SecretDelete

func (swarmClient *Client) SecretDelete(ctx context.Context, secret *swarm.Secret) error

SecretDelete removes the secret. The error tells, with docker.IsInUse, that a service still uses it.

func (*Client) SecretFind

func (swarmClient *Client) SecretFind(ctx context.Context, name string) (*swarm.Secret, error)

SecretFind returns the secret of that exact name, or nil.

func (*Client) SecretList

func (swarmClient *Client) SecretList(ctx context.Context, filters client.Filters) ([]swarm.Secret, error)

func (*Client) SecretUpdate

func (swarmClient *Client) SecretUpdate(ctx context.Context, existing *swarm.Secret, spec *swarm.SecretSpec) error

SecretUpdate replaces the labels of an existing secret: Swarm changes nothing else of a secret, its data least of all.

func (*Client) ServiceCreate

func (swarmClient *Client) ServiceCreate(ctx context.Context, spec *swarm.ServiceSpec, registryAuth string) (string, error)

ServiceCreate creates the service. Swarm hands the encoded registry credentials to the nodes that pull its image.

func (*Client) ServiceDelete

func (swarmClient *Client) ServiceDelete(ctx context.Context, service *swarm.Service) error

ServiceDelete removes the service. Swarm removes the containers of its tasks afterwards.

func (*Client) ServiceFind

func (swarmClient *Client) ServiceFind(ctx context.Context, name string) (*swarm.Service, error)

ServiceFind returns the service of that exact name, or nil.

func (*Client) ServiceList

func (swarmClient *Client) ServiceList(ctx context.Context, filters client.Filters) ([]swarm.Service, error)

ServiceList lists services, with their task counts.

func (*Client) ServiceUpdate

func (swarmClient *Client) ServiceUpdate(ctx context.Context, existing *swarm.Service, spec *swarm.ServiceSpec, registryAuth string) error

ServiceUpdate replaces the spec of an existing service, with the encoded registry credentials of its image.

func (*Client) TaskList

func (swarmClient *Client) TaskList(ctx context.Context, filters client.Filters) ([]swarm.Task, error)

type Orchestrator

type Orchestrator struct {
	// contains filtered or unexported fields
}

Orchestrator applies compose projects to the swarm a manager's daemon runs.

func (*Orchestrator) Close

func (orchestrator *Orchestrator) Close() error

func (*Orchestrator) Install

func (orchestrator *Orchestrator) Install(ctx context.Context, project *installer.Project, opts installer.InstallOptions) error

Install creates what the project declares and is not there yet, the way docker stack deploy does: volumes, networks, configs and secrets, then the services, level after level, each waited for until it converged. It then deletes the services, configs and secrets the project no longer declares.

func (*Orchestrator) Name

func (orchestrator *Orchestrator) Name() string

func (*Orchestrator) Uninstall

func (orchestrator *Orchestrator) Uninstall(ctx context.Context, project *installer.Project, opts installer.UninstallOptions) error

Uninstall deletes what Install created from the project, as docker stack rm does: its services, then its configs and secrets, its networks, and its volumes when asked. What Install deleted as orphans is not looked for.

func (*Orchestrator) Validate

func (orchestrator *Orchestrator) Validate(project *installer.Project) error

Directories

Path Synopsis
Package convert turns a compose project into the specs of Swarm objects, the way docker stack deploy does (docker/cli, cli/compose/convert).
Package convert turns a compose project into the specs of Swarm objects, the way docker stack deploy does (docker/cli, cli/compose/convert).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL