templatetypes

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2018 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DeprecatedProperties = map[string]string{
	"container_name": "Setting the container name is not supported.",
	"expose":         "Exposing ports is unnecessary - services on the same network can access each other's containers on any port.",
}

DeprecatedProperties that were removed from the v3 format, but their use should not impact the behaviour of the application.

View Source
var ForbiddenProperties = map[string]string{
	"extends":       "Support for `extends` is not implemented yet.",
	"volume_driver": "Instead of setting the volume driver on the service, define a volume using the top-level `volumes` option and specify the driver there.",
	"volumes_from":  "To share a volume between services, define it using the top-level `volumes` option and reference it from each service that shares it using the service-level `volumes` option.",
	"cpu_quota":     "Set resource limits using deploy.resources",
	"cpu_shares":    "Set resource limits using deploy.resources",
	"cpuset":        "Set resource limits using deploy.resources",
	"mem_limit":     "Set resource limits using deploy.resources",
	"memswap_limit": "Set resource limits using deploy.resources",
}

ForbiddenProperties that are not supported in this implementation of the compose file.

View Source
var UnsupportedProperties = []string{
	"build",
	"cap_add",
	"cap_drop",
	"cgroup_parent",
	"devices",
	"domainname",
	"external_links",
	"ipc",
	"links",
	"mac_address",
	"network_mode",
	"pid",
	"privileged",
	"restart",
	"security_opt",
	"shm_size",
	"sysctls",
	"ulimits",
	"userns_mode",
}

UnsupportedProperties not yet supported by this implementation of the compose file

Functions

This section is empty.

Types

type BoolOrTemplate

type BoolOrTemplate struct {
	Value         bool   `yaml:",omitempty"`
	ValueTemplate string `yaml:",omitempty"`
}

BoolOrTemplate stores a boolean or a templated string

type BuildConfig

type BuildConfig struct {
	Context    string            `yaml:",omitempty"`
	Dockerfile string            `yaml:",omitempty"`
	Args       MappingWithEquals `yaml:",omitempty"`
	Labels     Labels            `yaml:",omitempty"`
	CacheFrom  StringList        `mapstructure:"cache_from" yaml:"cache_from,omitempty"`
	Network    string            `yaml:",omitempty"`
	Target     string            `yaml:",omitempty"`
}

BuildConfig is a type for build using the same format at libcompose: https://github.com/docker/libcompose/blob/master/yaml/build.go#L12

type Config

type Config struct {
	Filename string `yaml:"-"`
	Version  string
	Services Services
	Networks map[string]NetworkConfig   `yaml:",omitempty"`
	Volumes  map[string]VolumeConfig    `yaml:",omitempty"`
	Secrets  map[string]SecretConfig    `yaml:",omitempty"`
	Configs  map[string]ConfigObjConfig `yaml:",omitempty"`
}

Config is a full compose file configuration

type ConfigDetails

type ConfigDetails struct {
	Version     string
	WorkingDir  string
	ConfigFiles []ConfigFile
	Environment map[string]string
}

ConfigDetails are the details about a group of ConfigFiles

func (ConfigDetails) LookupEnv

func (cd ConfigDetails) LookupEnv(key string) (string, bool)

LookupEnv provides a lookup function for environment variables

type ConfigFile

type ConfigFile struct {
	Filename string
	Config   map[string]interface{}
}

ConfigFile is a filename and the contents of the file as a Dict

type ConfigObjConfig

type ConfigObjConfig FileObjectConfig

ConfigObjConfig is the config for the swarm "Config" object

type CredentialSpecConfig

type CredentialSpecConfig struct {
	File     string `yaml:",omitempty"`
	Registry string `yaml:",omitempty"`
}

CredentialSpecConfig for credential spec on Windows

type DeployConfig

type DeployConfig struct {
	Mode          string           `yaml:",omitempty"`
	Replicas      UInt64OrTemplate `yaml:",omitempty"`
	Labels        Labels           `yaml:",omitempty"`
	UpdateConfig  *UpdateConfig    `mapstructure:"update_config" yaml:"update_config,omitempty"`
	Resources     Resources        `yaml:",omitempty"`
	RestartPolicy *RestartPolicy   `mapstructure:"restart_policy" yaml:"restart_policy,omitempty"`
	Placement     Placement        `yaml:",omitempty"`
	EndpointMode  string           `mapstructure:"endpoint_mode" yaml:"endpoint_mode,omitempty"`
}

DeployConfig the deployment configuration for a service

type DiscreteGenericResource

type DiscreteGenericResource struct {
	Kind  string
	Value int64
}

DiscreteGenericResource represents a "user defined" resource which is defined as an integer "Kind" is used to describe the Kind of a resource (e.g: "GPU", "FPGA", "SSD", ...) Value is used to count the resource (SSD=5, HDD=3, ...)

type DurationOrTemplate

type DurationOrTemplate struct {
	Value         *time.Duration `yaml:",omitempty"`
	ValueTemplate string         `yaml:",omitempty"`
}

DurationOrTemplate stores a duration or a templated string

type External

type External struct {
	Name     string `yaml:",omitempty"`
	External bool   `yaml:",omitempty"`
}

External identifies a Volume or Network as a reference to a resource that is not managed, and should already exist. External.name is deprecated and replaced by Volume.name

func (External) MarshalYAML

func (e External) MarshalYAML() (interface{}, error)

MarshalYAML makes External implement yaml.Marshaller

type FileObjectConfig

type FileObjectConfig struct {
	Name     string   `yaml:",omitempty"`
	File     string   `yaml:",omitempty"`
	External External `yaml:",omitempty"`
	Labels   Labels   `yaml:",omitempty"`
}

FileObjectConfig is a config type for a file used by a service

type FileReferenceConfig

type FileReferenceConfig struct {
	Source string           `yaml:",omitempty"`
	Target string           `yaml:",omitempty"`
	UID    string           `yaml:",omitempty"`
	GID    string           `yaml:",omitempty"`
	Mode   UInt64OrTemplate `yaml:",omitempty"`
}

FileReferenceConfig for a reference to a swarm file object

type GenericResource

type GenericResource struct {
	DiscreteResourceSpec *DiscreteGenericResource `mapstructure:"discrete_resource_spec" yaml:"discrete_resource_spec,omitempty"`
}

GenericResource represents a "user defined" resource which can only be an integer (e.g: SSD=3) for a service

type HealthCheckConfig

type HealthCheckConfig struct {
	Test        HealthCheckTest    `yaml:",omitempty"`
	Timeout     DurationOrTemplate `yaml:",omitempty"`
	Interval    DurationOrTemplate `yaml:",omitempty"`
	Retries     UInt64OrTemplate   `yaml:",omitempty"`
	StartPeriod *time.Duration     `mapstructure:"start_period" yaml:"start_period,omitempty"`
	Disable     bool               `yaml:",omitempty"`
}

HealthCheckConfig the healthcheck configuration for a service

type HealthCheckTest

type HealthCheckTest []string

HealthCheckTest is the command run to test the health of a service

type HostsList

type HostsList []string

HostsList is a list of colon-separated host-ip mappings

type IPAMConfig

type IPAMConfig struct {
	Driver string      `yaml:",omitempty"`
	Config []*IPAMPool `yaml:",omitempty"`
}

IPAMConfig for a network

type IPAMPool

type IPAMPool struct {
	Subnet string `yaml:",omitempty"`
}

IPAMPool for a network

type Labels

type Labels map[string]string

Labels is a mapping type for labels

type LoggingConfig

type LoggingConfig struct {
	Driver  string            `yaml:",omitempty"`
	Options map[string]string `yaml:",omitempty"`
}

LoggingConfig the logging configuration for a service

type MappingWithColon

type MappingWithColon map[string]string

MappingWithColon is a mapping type that can be converted from a list of 'key: value' strings

type MappingWithEquals

type MappingWithEquals map[string]*string

MappingWithEquals is a mapping type that can be converted from a list of key[=value] strings. For the key with an empty value (`key=`), the mapped value is set to a pointer to `""`. For the key without value (`key`), the mapped value is set to nil.

type NetworkConfig

type NetworkConfig struct {
	Name       string            `yaml:",omitempty"`
	Driver     string            `yaml:",omitempty"`
	DriverOpts map[string]string `mapstructure:"driver_opts" yaml:"driver_opts,omitempty"`
	Ipam       IPAMConfig        `yaml:",omitempty"`
	External   External          `yaml:",omitempty"`
	Internal   bool              `yaml:",omitempty"`
	Attachable bool              `yaml:",omitempty"`
	Labels     Labels            `yaml:",omitempty"`
}

NetworkConfig for a network

type Placement

type Placement struct {
	Constraints []string               `yaml:",omitempty"`
	Preferences []PlacementPreferences `yaml:",omitempty"`
}

Placement constraints for the service

type PlacementPreferences

type PlacementPreferences struct {
	Spread string `yaml:",omitempty"`
}

PlacementPreferences is the preferences for a service placement

type Resource

type Resource struct {
	// TODO: types to convert from units and ratios
	NanoCPUs         string              `mapstructure:"cpus" yaml:"cpus,omitempty"`
	MemoryBytes      UnitBytesOrTemplate `mapstructure:"memory" yaml:"memory,omitempty"`
	GenericResources []GenericResource   `mapstructure:"generic_resources" yaml:"generic_resources,omitempty"`
}

Resource is a resource to be limited or reserved

type Resources

type Resources struct {
	Limits       *Resource `yaml:",omitempty"`
	Reservations *Resource `yaml:",omitempty"`
}

Resources the resource limits and reservations

type RestartPolicy

type RestartPolicy struct {
	Condition   string         `yaml:",omitempty"`
	Delay       *time.Duration `yaml:",omitempty"`
	MaxAttempts *uint64        `mapstructure:"max_attempts" yaml:"max_attempts,omitempty"`
	Window      *time.Duration `yaml:",omitempty"`
}

RestartPolicy the service restart policy

type SecretConfig

type SecretConfig FileObjectConfig

SecretConfig for a secret

type ServiceConfig

type ServiceConfig struct {
	Name string `yaml:"-"`

	Build           BuildConfig                      `yaml:",omitempty"`
	CapAdd          []string                         `mapstructure:"cap_add" yaml:"cap_add,omitempty"`
	CapDrop         []string                         `mapstructure:"cap_drop" yaml:"cap_drop,omitempty"`
	CgroupParent    string                           `mapstructure:"cgroup_parent" yaml:"cgroup_parent,omitempty"`
	Command         ShellCommand                     `yaml:",omitempty"`
	Configs         []ServiceConfigObjConfig         `yaml:",omitempty"`
	ContainerName   string                           `mapstructure:"container_name" yaml:"container_name,omitempty"`
	CredentialSpec  CredentialSpecConfig             `mapstructure:"credential_spec" yaml:"credential_spec,omitempty"`
	DependsOn       []string                         `mapstructure:"depends_on" yaml:"depends_on,omitempty"`
	Deploy          DeployConfig                     `yaml:",omitempty"`
	Devices         []string                         `yaml:",omitempty"`
	DNS             StringList                       `yaml:",omitempty"`
	DNSSearch       StringList                       `mapstructure:"dns_search" yaml:"dns_search,omitempty"`
	DomainName      string                           `mapstructure:"domainname" yaml:"domainname,omitempty"`
	Entrypoint      ShellCommand                     `yaml:",omitempty"`
	Environment     MappingWithEquals                `yaml:",omitempty"`
	EnvFile         StringList                       `mapstructure:"env_file" yaml:"env_file,omitempty"`
	Expose          StringOrNumberList               `yaml:",omitempty"`
	ExternalLinks   []string                         `mapstructure:"external_links" yaml:"external_links,omitempty"`
	ExtraHosts      HostsList                        `mapstructure:"extra_hosts" yaml:"extra_hosts,omitempty"`
	Hostname        string                           `yaml:",omitempty"`
	HealthCheck     *HealthCheckConfig               `yaml:",omitempty"`
	Image           string                           `yaml:",omitempty"`
	Ipc             string                           `yaml:",omitempty"`
	Labels          Labels                           `yaml:",omitempty"`
	Links           []string                         `yaml:",omitempty"`
	Logging         *LoggingConfig                   `yaml:",omitempty"`
	MacAddress      string                           `mapstructure:"mac_address" yaml:"mac_address,omitempty"`
	NetworkMode     string                           `mapstructure:"network_mode" yaml:"network_mode,omitempty"`
	Networks        map[string]*ServiceNetworkConfig `yaml:",omitempty"`
	Pid             string                           `yaml:",omitempty"`
	Ports           []ServicePortConfig              `yaml:",omitempty"`
	Privileged      BoolOrTemplate                   `yaml:"template_privileged,omitempty"`
	ReadOnly        BoolOrTemplate                   `mapstructure:"read_only" yaml:"read_only,omitempty"`
	Restart         string                           `yaml:",omitempty"`
	Secrets         []ServiceSecretConfig            `yaml:",omitempty"`
	SecurityOpt     []string                         `mapstructure:"security_opt" yaml:"security_opt,omitempty"`
	StdinOpen       BoolOrTemplate                   `mapstructure:"stdin_open" yaml:"stdin_open,omitempty"`
	StopGracePeriod DurationOrTemplate               `mapstructure:"stop_grace_period" yaml:"stop_grace_period,omitempty"`
	StopSignal      string                           `mapstructure:"stop_signal" yaml:"stop_signal,omitempty"`
	Tmpfs           StringList                       `yaml:",omitempty"`
	Tty             BoolOrTemplate                   `mapstructure:"tty" yaml:"tty,omitempty"`
	Ulimits         map[string]*UlimitsConfig        `yaml:",omitempty"`
	User            string                           `yaml:",omitempty"`
	Volumes         []ServiceVolumeConfig            `yaml:",omitempty"`
	WorkingDir      string                           `mapstructure:"working_dir" yaml:"working_dir,omitempty"`
	Isolation       string                           `mapstructure:"isolation" yaml:"isolation,omitempty"`
}

ServiceConfig is the configuration of one service

type ServiceConfigObjConfig

type ServiceConfigObjConfig FileReferenceConfig

ServiceConfigObjConfig is the config obj configuration for a service

type ServiceNetworkConfig

type ServiceNetworkConfig struct {
	Aliases     []string `yaml:",omitempty"`
	Ipv4Address string   `mapstructure:"ipv4_address" yaml:"ipv4_address,omitempty"`
	Ipv6Address string   `mapstructure:"ipv6_address" yaml:"ipv6_address,omitempty"`
}

ServiceNetworkConfig is the network configuration for a service

type ServicePortConfig

type ServicePortConfig struct {
	Mode      string           `yaml:",omitempty"`
	Target    UInt64OrTemplate `yaml:",omitempty"`
	Published UInt64OrTemplate `yaml:",omitempty"`
	Protocol  string           `yaml:",omitempty"`
}

ServicePortConfig is the port configuration for a service

type ServiceSecretConfig

type ServiceSecretConfig FileReferenceConfig

ServiceSecretConfig is the secret configuration for a service

type ServiceVolumeBind

type ServiceVolumeBind struct {
	Propagation string `yaml:",omitempty"`
}

ServiceVolumeBind are options for a service volume of type bind

type ServiceVolumeConfig

type ServiceVolumeConfig struct {
	Type        string               `yaml:",omitempty"`
	Source      string               `yaml:",omitempty"`
	Target      string               `yaml:",omitempty"`
	ReadOnly    BoolOrTemplate       `mapstructure:"read_only" yaml:"read_only,omitempty"`
	Consistency string               `yaml:",omitempty"`
	Bind        *ServiceVolumeBind   `yaml:",omitempty"`
	Volume      *ServiceVolumeVolume `yaml:",omitempty"`
	Tmpfs       *ServiceVolumeTmpfs  `yaml:",omitempty"`
}

ServiceVolumeConfig are references to a volume used by a service

type ServiceVolumeTmpfs

type ServiceVolumeTmpfs struct {
	Size int64 `yaml:",omitempty"`
}

ServiceVolumeTmpfs are options for a service volume of type tmpfs

type ServiceVolumeVolume

type ServiceVolumeVolume struct {
	NoCopy bool `mapstructure:"nocopy" yaml:"nocopy,omitempty"`
}

ServiceVolumeVolume are options for a service volume of type volume

type Services

type Services []ServiceConfig

Services is a list of ServiceConfig

func (Services) MarshalYAML

func (s Services) MarshalYAML() (interface{}, error)

MarshalYAML makes Services implement yaml.Marshaller

type ShellCommand

type ShellCommand []string

ShellCommand is a string or list of string args

type StringList

type StringList []string

StringList is a type for fields that can be a string or list of strings

type StringOrNumberList

type StringOrNumberList []string

StringOrNumberList is a type for fields that can be a list of strings or numbers

type UInt64OrTemplate

type UInt64OrTemplate struct {
	Value         *uint64 `yaml:",omitempty"`
	ValueTemplate string  `yaml:",omitempty"`
}

UInt64OrTemplate stores an uint64 or a templated string

type UlimitsConfig

type UlimitsConfig struct {
	Single int `yaml:",omitempty"`
	Soft   int `yaml:",omitempty"`
	Hard   int `yaml:",omitempty"`
}

UlimitsConfig the ulimit configuration

func (*UlimitsConfig) MarshalYAML

func (u *UlimitsConfig) MarshalYAML() (interface{}, error)

MarshalYAML makes UlimitsConfig implement yaml.Marshaller

type UnitBytes

type UnitBytes int64

UnitBytes is the bytes type

func (UnitBytes) MarshalYAML

func (u UnitBytes) MarshalYAML() (interface{}, error)

MarshalYAML makes UnitBytes implement yaml.Marshaller

type UnitBytesOrTemplate

type UnitBytesOrTemplate struct {
	Value         int64  `yaml:",omitempty"`
	ValueTemplate string `yaml:",omitempty"`
}

UnitBytesOrTemplate stores an int64 parsed from a size or a templated string

type UpdateConfig

type UpdateConfig struct {
	Parallelism     UInt64OrTemplate `yaml:",omitempty"`
	Delay           time.Duration    `yaml:",omitempty"`
	FailureAction   string           `mapstructure:"failure_action" yaml:"failure_action,omitempty"`
	Monitor         time.Duration    `yaml:",omitempty"`
	MaxFailureRatio float32          `mapstructure:"max_failure_ratio" yaml:"max_failure_ratio,omitempty"`
	Order           string           `yaml:",omitempty"`
}

UpdateConfig the service update configuration

type VolumeConfig

type VolumeConfig struct {
	Name       string            `yaml:",omitempty"`
	Driver     string            `yaml:",omitempty"`
	DriverOpts map[string]string `mapstructure:"driver_opts" yaml:"driver_opts,omitempty"`
	External   External          `yaml:",omitempty"`
	Labels     Labels            `yaml:",omitempty"`
}

VolumeConfig for a volume

Jump to

Keyboard shortcuts

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