2016-12-20 16:26:49 -05:00
package types
import (
"time"
)
// UnsupportedProperties not yet supported by this implementation of the compose file
var UnsupportedProperties = [ ] string {
"build" ,
"cap_add" ,
"cap_drop" ,
"cgroup_parent" ,
"devices" ,
"dns" ,
"dns_search" ,
"domainname" ,
"external_links" ,
"ipc" ,
"links" ,
"mac_address" ,
"network_mode" ,
"privileged" ,
"read_only" ,
"restart" ,
"security_opt" ,
"shm_size" ,
"stop_signal" ,
2017-01-04 10:06:59 -05:00
"sysctls" ,
2016-12-20 16:26:49 -05:00
"tmpfs" ,
2017-01-04 10:06:59 -05:00
"userns_mode" ,
2016-12-20 16:26:49 -05:00
}
// DeprecatedProperties that were removed from the v3 format, but their
// use should not impact the behaviour of the application.
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." ,
}
// ForbiddenProperties that are not supported in this implementation of the
// compose file.
var ForbiddenProperties = map [ string ] string {
2017-01-11 11:57:24 -05:00
"extends" : "Support for `extends` is not implemented yet." ,
2016-12-20 16:26:49 -05:00
"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" ,
}
// Dict is a mapping of strings to interface{}
type Dict map [ string ] interface { }
// ConfigFile is a filename and the contents of the file as a Dict
type ConfigFile struct {
Filename string
Config Dict
}
// ConfigDetails are the details about a group of ConfigFiles
type ConfigDetails struct {
WorkingDir string
ConfigFiles [ ] ConfigFile
Environment map [ string ] string
}
// Config is a full compose file configuration
type Config struct {
Services [ ] ServiceConfig
Networks map [ string ] NetworkConfig
Volumes map [ string ] VolumeConfig
2017-01-10 17:40:53 -05:00
Secrets map [ string ] SecretConfig
2016-12-20 16:26:49 -05:00
}
// ServiceConfig is the configuration of one service
type ServiceConfig struct {
Name string
CapAdd [ ] string ` mapstructure:"cap_add" `
CapDrop [ ] string ` mapstructure:"cap_drop" `
CgroupParent string ` mapstructure:"cgroup_parent" `
2017-01-18 15:27:02 -05:00
Command ShellCommand
2016-12-20 16:26:49 -05:00
ContainerName string ` mapstructure:"container_name" `
DependsOn [ ] string ` mapstructure:"depends_on" `
Deploy DeployConfig
Devices [ ] string
2017-01-18 15:27:02 -05:00
DNS StringList
DNSSearch StringList ` mapstructure:"dns_search" `
DomainName string ` mapstructure:"domainname" `
Entrypoint ShellCommand
Environment MappingWithEquals
EnvFile StringList ` mapstructure:"env_file" `
Expose StringOrNumberList
ExternalLinks [ ] string ` mapstructure:"external_links" `
ExtraHosts MappingWithColon ` mapstructure:"extra_hosts" `
2016-12-20 16:26:49 -05:00
Hostname string
HealthCheck * HealthCheckConfig
Image string
Ipc string
2017-01-18 15:27:02 -05:00
Labels MappingWithEquals
2016-12-20 16:26:49 -05:00
Links [ ] string
Logging * LoggingConfig
2017-01-18 15:27:02 -05:00
MacAddress string ` mapstructure:"mac_address" `
NetworkMode string ` mapstructure:"network_mode" `
Networks map [ string ] * ServiceNetworkConfig
2016-12-20 16:26:49 -05:00
Pid string
2017-01-31 15:44:05 -05:00
Ports [ ] ServicePortConfig
2016-12-20 16:26:49 -05:00
Privileged bool
ReadOnly bool ` mapstructure:"read_only" `
Restart string
2017-01-10 17:40:53 -05:00
Secrets [ ] ServiceSecretConfig
2016-12-20 16:26:49 -05:00
SecurityOpt [ ] string ` mapstructure:"security_opt" `
StdinOpen bool ` mapstructure:"stdin_open" `
StopGracePeriod * time . Duration ` mapstructure:"stop_grace_period" `
StopSignal string ` mapstructure:"stop_signal" `
2017-01-18 15:27:02 -05:00
Tmpfs StringList
Tty bool ` mapstructure:"tty" `
2016-12-20 16:26:49 -05:00
Ulimits map [ string ] * UlimitsConfig
User string
Volumes [ ] string
WorkingDir string ` mapstructure:"working_dir" `
}
2017-01-18 15:27:02 -05:00
// ShellCommand is a string or list of string args
type ShellCommand [ ] string
// StringList is a type for fields that can be a string or list of strings
type StringList [ ] string
// StringOrNumberList is a type for fields that can be a list of strings or
// numbers
type StringOrNumberList [ ] string
// MappingWithEquals is a mapping type that can be converted from a list of
// key=value strings
type MappingWithEquals map [ string ] string
2017-02-16 10:56:53 -05:00
// MappingWithColon is a mapping type that can be converted from a list of
2017-01-18 15:27:02 -05:00
// 'key: value' strings
type MappingWithColon map [ string ] string
2016-12-20 16:26:49 -05:00
// LoggingConfig the logging configuration for a service
type LoggingConfig struct {
Driver string
Options map [ string ] string
}
// DeployConfig the deployment configuration for a service
type DeployConfig struct {
Mode string
Replicas * uint64
2017-01-18 15:27:02 -05:00
Labels MappingWithEquals
UpdateConfig * UpdateConfig ` mapstructure:"update_config" `
2016-12-20 16:26:49 -05:00
Resources Resources
RestartPolicy * RestartPolicy ` mapstructure:"restart_policy" `
Placement Placement
}
// HealthCheckConfig the healthcheck configuration for a service
type HealthCheckConfig struct {
2017-01-18 15:27:02 -05:00
Test HealthCheckTest
2016-12-20 16:26:49 -05:00
Timeout string
Interval string
Retries * uint64
Disable bool
}
2017-01-18 15:27:02 -05:00
// HealthCheckTest is the command run to test the health of a service
type HealthCheckTest [ ] string
2016-12-20 16:26:49 -05:00
// UpdateConfig the service update configuration
type UpdateConfig struct {
Parallelism * uint64
Delay time . Duration
FailureAction string ` mapstructure:"failure_action" `
Monitor time . Duration
MaxFailureRatio float32 ` mapstructure:"max_failure_ratio" `
}
// Resources the resource limits and reservations
type Resources struct {
Limits * Resource
Reservations * Resource
}
// Resource is a resource to be limited or reserved
type Resource struct {
// TODO: types to convert from units and ratios
NanoCPUs string ` mapstructure:"cpus" `
MemoryBytes UnitBytes ` mapstructure:"memory" `
}
// UnitBytes is the bytes type
type UnitBytes int64
// RestartPolicy the service restart policy
type RestartPolicy struct {
Condition string
Delay * time . Duration
MaxAttempts * uint64 ` mapstructure:"max_attempts" `
Window * time . Duration
}
// Placement constraints for the service
type Placement struct {
Constraints [ ] string
}
// ServiceNetworkConfig is the network configuration for a service
type ServiceNetworkConfig struct {
Aliases [ ] string
Ipv4Address string ` mapstructure:"ipv4_address" `
Ipv6Address string ` mapstructure:"ipv6_address" `
}
2017-01-31 15:44:05 -05:00
// ServicePortConfig is the port configuration for a service
type ServicePortConfig struct {
Mode string
Target uint32
Published uint32
Protocol string
}
2017-01-10 17:40:53 -05:00
// ServiceSecretConfig is the secret configuration for a service
type ServiceSecretConfig struct {
Source string
Target string
UID string
GID string
2017-02-14 09:12:03 -05:00
Mode * uint32
2017-01-10 17:40:53 -05:00
}
2016-12-20 16:26:49 -05:00
// UlimitsConfig the ulimit configuration
type UlimitsConfig struct {
Single int
Soft int
Hard int
}
// NetworkConfig for a network
type NetworkConfig struct {
Driver string
DriverOpts map [ string ] string ` mapstructure:"driver_opts" `
Ipam IPAMConfig
External External
2017-01-20 12:53:19 -05:00
Internal bool
2017-02-04 16:55:28 -05:00
Attachable bool
2017-01-18 15:27:02 -05:00
Labels MappingWithEquals
2016-12-20 16:26:49 -05:00
}
// IPAMConfig for a network
type IPAMConfig struct {
Driver string
Config [ ] * IPAMPool
}
// IPAMPool for a network
type IPAMPool struct {
Subnet string
}
// VolumeConfig for a volume
type VolumeConfig struct {
Driver string
DriverOpts map [ string ] string ` mapstructure:"driver_opts" `
External External
2017-01-18 15:27:02 -05:00
Labels MappingWithEquals
2016-12-20 16:26:49 -05:00
}
// External identifies a Volume or Network as a reference to a resource that is
// not managed, and should already exist.
type External struct {
Name string
External bool
}
2017-01-10 17:40:53 -05:00
// SecretConfig for a secret
type SecretConfig struct {
File string
External External
2017-01-18 15:27:02 -05:00
Labels MappingWithEquals
2017-01-10 17:40:53 -05:00
}