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

convert

package
v0.3.2 Latest Latest
Warning

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

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

Documentation

Overview

Package convert turns a compose project into the specs of Swarm objects, the way docker stack deploy does (docker/cli, cli/compose/convert). It only computes: creating the objects is the orchestrator's job.

Index

Constants

View Source
const LabelNamespace = "com.docker.stack.namespace"

LabelNamespace lets docker stack ps and docker stack rm see what nemo created.

Variables

This section is empty.

Functions

func AddStackLabel

func AddStackLabel(namespace Namespace, labels map[string]string) map[string]string

AddStackLabel returns a copy of the labels with the namespace label added

func Config

func Config(key string, config types.ConfigObjConfig, base map[string]string) (*swarm.ConfigSpec, error)

Config converts a compose config into the spec of a Swarm config, named after its content. An external config, which is only referenced, has no data.

func Hash

func Hash(spec *swarm.ServiceSpec) (string, error)

Hash identifies a service spec, whatever its hash and revision labels say: a service is only updated when its hash changed.

func Mounts

func Mounts(service types.ServiceConfig, volumes types.Volumes, base map[string]string) ([]mount.Mount, error)

Mounts converts the volumes and tmpfs of a service. A volume of the project carries its labels and driver, so that Swarm creates it on every node.

func Network

func Network(network types.NetworkConfig, base map[string]string) (docker.NetworkSpec, error)

Network converts a compose network into a Swarm network to create, as docker stack deploy does: an overlay network of swarm scope.

func Secret

func Secret(key string, secret types.SecretConfig, base map[string]string) (*swarm.SecretSpec, error)

Secret converts a compose secret into the spec of a Swarm secret, named after its content. An external secret, which is only referenced, has no data.

func Service

func Service(namespace Namespace, project *types.Project, service types.ServiceConfig, configs, secrets, base map[string]string) (*swarm.ServiceSpec, error)

Service converts a compose service into the spec of a Swarm service. configs and secrets map the compose keys to the names of the Swarm objects; base holds the labels of the installation.

As with docker stack deploy, deploy.labels go on the service and labels on its containers.

func Volume

func Volume(config types.VolumeConfig, base map[string]string) *volume.Volume

Volume converts a compose volume into the volume to create on the manager.

Types

type Namespace

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

Namespace mangles names by prepending the name

func NewNamespace

func NewNamespace(name string) Namespace

NewNamespace returns a new Namespace for scoping of names

func (Namespace) Descope

func (namespace Namespace) Descope(name string) string

Descope returns the name without the namespace prefix

func (Namespace) Name

func (namespace Namespace) Name() string

Name returns the name of the namespace

func (Namespace) Scope

func (namespace Namespace) Scope(name string) string

Scope prepends the namespace to a name

Jump to

Keyboard shortcuts

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