compose

package
v0.8.6 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2021 License: MIT Imports: 38 Imported by: 0

README

Documentation

Index

Constants

View Source
const (

	// LabelImage is the label used to store image name provided in the compose file
	LabelImage = "com.docker.stack.image"
)
View Source
const (
	// LabelNamespace is the label used to track stack resources
	LabelNamespace = "com.docker.stack.namespace"
)

Variables

This section is empty.

Functions

func AddStackLabel

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

AddStackLabel returns labels with the namespace label added

func Configs

func Configs(namespace Namespace, configs map[string]composetypes.ConfigObjConfig) ([]swarm.ConfigSpec, error)

Configs converts config objects from the Compose type to the engine API type

func ConvertKVStringsToMapWithNil

func ConvertKVStringsToMapWithNil(values []string) map[string]*string

ConvertKVStringsToMapWithNil converts ["key=value"] to {"key":"value"} but set unset keys to nil - meaning the ones with no "=" in them. We use this in cases where we need to distinguish between

FOO=  and FOO

where the latter case just means FOO was mentioned but not given a value

func ConvertPortToPortConfig

func ConvertPortToPortConfig(
	port nat.Port,
	portBindings map[nat.Port][]nat.PortBinding,
) ([]swarm.PortConfig, error)

ConvertPortToPortConfig converts ports to the swarm type

func GetDeprecatedProperties

func GetDeprecatedProperties(configDicts ...map[string]interface{}) map[string]string

GetDeprecatedProperties returns the list of any deprecated properties that are used in the compose files.

func GetServicesDeclaredNetworks

func GetServicesDeclaredNetworks(serviceConfigs []composetypes.ServiceConfig) map[string]struct{}

func GetUnsupportedProperties

func GetUnsupportedProperties(configDicts ...map[string]interface{}) []string

GetUnsupportedProperties returns the list of any unsupported properties that are used in the Compose files.

func Load

func Load(configDetails composetypes.ConfigDetails, options ...func(*Options)) (*composetypes.Config, error)

Load reads a ConfigDetails and returns a fully loaded configuration

func LoadConfigObjs

func LoadConfigObjs(source map[string]interface{}, details composetypes.ConfigDetails) (map[string]composetypes.ConfigObjConfig, error)

LoadConfigObjs produces a ConfigObjConfig map from a compose file Dict the source Dict is not validated if directly used. Use Load() to enable validation

func LoadNetworks

func LoadNetworks(source map[string]interface{}, version string) (map[string]composetypes.NetworkConfig, error)

LoadNetworks produces a NetworkConfig map from a compose file Dict the source Dict is not validated if directly used. Use Load() to enable validation

func LoadSecrets

func LoadSecrets(source map[string]interface{}, details composetypes.ConfigDetails) (map[string]composetypes.SecretConfig, error)

LoadSecrets produces a SecretConfig map from a compose file Dict the source Dict is not validated if directly used. Use Load() to enable validation

func LoadService

func LoadService(name string, serviceDict map[string]interface{}, workingDir string, lookupEnv template.Mapping) (*composetypes.ServiceConfig, error)

LoadService produces a single ServiceConfig from a compose file Dict the serviceDict is not validated if directly used. Use Load() to enable validation

func LoadServices

func LoadServices(servicesDict map[string]interface{}, workingDir string, lookupEnv template.Mapping) ([]composetypes.ServiceConfig, error)

LoadServices produces a ServiceConfig map from a compose file Dict the servicesDict is not validated if directly used. Use Load() to enable validation

func LoadVolumes

func LoadVolumes(source map[string]interface{}, version string) (map[string]composetypes.VolumeConfig, error)

LoadVolumes produces a VolumeConfig map from a compose file Dict the source Dict is not validated if directly used. Use Load() to enable validation

func Networks

func Networks(namespace Namespace, networks networkMap, servicesNetworks map[string]struct{}) (map[string]types.NetworkCreate, []string)

Networks from the compose-file type to the engine API type

func Parse

func Parse(name, content string) (*composetypes.Config, error)

func ParseCPUs

func ParseCPUs(value string) (int64, error)

ParseCPUs takes a string ratio and returns an integer value of nano cpus

func ParseConfigs

func ParseConfigs(client client.ConfigAPIClient, requestedConfigs []*swarm.ConfigReference) ([]*swarm.ConfigReference, error)

ParseConfigs retrieves the configs from the requested names and converts them to config references to use with the spec

func ParseEnvFile

func ParseEnvFile(filename string) ([]string, error)

ParseEnvFile reads a file with environment variables enumerated by lines

“Environment variable names used by the utilities in the Shell and Utilities volume of IEEE Std 1003.1-2001 consist solely of uppercase letters, digits, and the '_' (underscore) from the characters defined in Portable Character Set and do not begin with a digit. *But*, other characters may be permitted by an implementation; applications shall tolerate the presence of such names.” -- http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html

As of #16585, it's up to application inside docker to validate or not environment variables, that's why we just strip leading whitespace and nothing more.

func ParseRestartPolicy

func ParseRestartPolicy(policy string) (container.RestartPolicy, error)

ParseRestartPolicy returns the parsed policy or an error indicating what is incorrect

func ParseSecrets

func ParseSecrets(client *client.Client, requestedSecrets []*swarm.SecretReference) ([]*swarm.SecretReference, error)

ParseSecrets retrieves the secrets with the requested names and fills secret IDs into the secret references.

func ParseVolume

func ParseVolume(spec string) (types.ServiceVolumeConfig, error)

ParseVolume parses a volume spec without any knowledge of the target platform

func ParseYAML

func ParseYAML(source []byte) (map[string]interface{}, error)

ParseYAML reads the bytes from a file, parses the bytes into a mapping structure, and returns it.

func Secrets

func Secrets(namespace Namespace, secrets map[string]composetypes.SecretConfig) ([]swarm.SecretSpec, error)

Secrets converts secrets from the Compose type to the engine API type

func Service

func Service(
	apiVersion string,
	namespace Namespace,
	service composetypes.ServiceConfig,
	networkConfigs map[string]composetypes.NetworkConfig,
	volumes map[string]composetypes.VolumeConfig,
	secrets []*swarm.SecretReference,
	configs []*swarm.ConfigReference,
) (swarm.ServiceSpec, error)

Service converts a ServiceConfig into a swarm ServiceSpec

func Services

func Services(
	namespace Namespace,
	config *composetypes.Config,
	client *client.Client,
) (map[string]swarm.ServiceSpec, error)

Services from compose-file types to engine API types

func Transform added in v0.8.6

func Transform(source interface{}, target interface{}, additionalTransformers ...Transformer) error

Transform converts the source into the target struct with compose types transformer and the specified transformers if any.

func Volumes

func Volumes(serviceVolumes []composetypes.ServiceVolumeConfig, stackVolumes volumes, namespace Namespace) ([]mount.Mount, error)

Volumes from compose-file types to engine api types

Types

type ErrBadEnvVariable

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

ErrBadEnvVariable typed error for bad environment variable

func (ErrBadEnvVariable) Error

func (e ErrBadEnvVariable) Error() string

type ForbiddenPropertiesError

type ForbiddenPropertiesError struct {
	Properties map[string]string
}

ForbiddenPropertiesError is returned when there are properties in the Compose file that are forbidden.

func (*ForbiddenPropertiesError) Error

func (e *ForbiddenPropertiesError) Error() string

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 (n Namespace) Descope(name string) string

Descope returns the name without the namespace prefix

func (Namespace) Name

func (n Namespace) Name() string

Name returns the name of the namespace

func (Namespace) Scope

func (n Namespace) Scope(name string) string

Scope prepends the namespace to a name

type Options added in v0.8.6

type Options struct {
	// Skip schema validation
	SkipValidation bool
	// Skip interpolation
	SkipInterpolation bool
	// Interpolation options
	Interpolate *interp.Options
}

Options supported by Load

type PortOpt

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

PortOpt represents a port config in swarm mode.

func (*PortOpt) Set

func (p *PortOpt) Set(value string) error

Set a new port value nolint: gocyclo

func (*PortOpt) String

func (p *PortOpt) String() string

String returns a string repr of this option

func (*PortOpt) Type

func (p *PortOpt) Type() string

Type returns the type of this option

func (*PortOpt) Value

func (p *PortOpt) Value() []swarm.PortConfig

Value returns the ports

type Transformer added in v0.8.6

type Transformer struct {
	TypeOf reflect.Type
	Func   func(interface{}) (interface{}, error)
}

Transformer defines a map to type transformer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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