github.com/fabiokung/docker@v0.11.2-0.20170222101415-4534dcd49497/cli/compose/types/types.go (about) 1 package types 2 3 import ( 4 "time" 5 ) 6 7 // UnsupportedProperties not yet supported by this implementation of the compose file 8 var UnsupportedProperties = []string{ 9 "build", 10 "cap_add", 11 "cap_drop", 12 "cgroup_parent", 13 "devices", 14 "dns", 15 "dns_search", 16 "domainname", 17 "external_links", 18 "ipc", 19 "links", 20 "mac_address", 21 "network_mode", 22 "privileged", 23 "read_only", 24 "restart", 25 "security_opt", 26 "shm_size", 27 "stop_signal", 28 "sysctls", 29 "tmpfs", 30 "userns_mode", 31 } 32 33 // DeprecatedProperties that were removed from the v3 format, but their 34 // use should not impact the behaviour of the application. 35 var DeprecatedProperties = map[string]string{ 36 "container_name": "Setting the container name is not supported.", 37 "expose": "Exposing ports is unnecessary - services on the same network can access each other's containers on any port.", 38 } 39 40 // ForbiddenProperties that are not supported in this implementation of the 41 // compose file. 42 var ForbiddenProperties = map[string]string{ 43 "extends": "Support for `extends` is not implemented yet.", 44 "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.", 45 "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.", 46 "cpu_quota": "Set resource limits using deploy.resources", 47 "cpu_shares": "Set resource limits using deploy.resources", 48 "cpuset": "Set resource limits using deploy.resources", 49 "mem_limit": "Set resource limits using deploy.resources", 50 "memswap_limit": "Set resource limits using deploy.resources", 51 } 52 53 // Dict is a mapping of strings to interface{} 54 type Dict map[string]interface{} 55 56 // ConfigFile is a filename and the contents of the file as a Dict 57 type ConfigFile struct { 58 Filename string 59 Config Dict 60 } 61 62 // ConfigDetails are the details about a group of ConfigFiles 63 type ConfigDetails struct { 64 WorkingDir string 65 ConfigFiles []ConfigFile 66 Environment map[string]string 67 } 68 69 // Config is a full compose file configuration 70 type Config struct { 71 Services []ServiceConfig 72 Networks map[string]NetworkConfig 73 Volumes map[string]VolumeConfig 74 Secrets map[string]SecretConfig 75 } 76 77 // ServiceConfig is the configuration of one service 78 type ServiceConfig struct { 79 Name string 80 81 CapAdd []string `mapstructure:"cap_add"` 82 CapDrop []string `mapstructure:"cap_drop"` 83 CgroupParent string `mapstructure:"cgroup_parent"` 84 Command ShellCommand 85 ContainerName string `mapstructure:"container_name"` 86 DependsOn []string `mapstructure:"depends_on"` 87 Deploy DeployConfig 88 Devices []string 89 DNS StringList 90 DNSSearch StringList `mapstructure:"dns_search"` 91 DomainName string `mapstructure:"domainname"` 92 Entrypoint ShellCommand 93 Environment MappingWithEquals 94 EnvFile StringList `mapstructure:"env_file"` 95 Expose StringOrNumberList 96 ExternalLinks []string `mapstructure:"external_links"` 97 ExtraHosts MappingWithColon `mapstructure:"extra_hosts"` 98 Hostname string 99 HealthCheck *HealthCheckConfig 100 Image string 101 Ipc string 102 Labels MappingWithEquals 103 Links []string 104 Logging *LoggingConfig 105 MacAddress string `mapstructure:"mac_address"` 106 NetworkMode string `mapstructure:"network_mode"` 107 Networks map[string]*ServiceNetworkConfig 108 Pid string 109 Ports []ServicePortConfig 110 Privileged bool 111 ReadOnly bool `mapstructure:"read_only"` 112 Restart string 113 Secrets []ServiceSecretConfig 114 SecurityOpt []string `mapstructure:"security_opt"` 115 StdinOpen bool `mapstructure:"stdin_open"` 116 StopGracePeriod *time.Duration `mapstructure:"stop_grace_period"` 117 StopSignal string `mapstructure:"stop_signal"` 118 Tmpfs StringList 119 Tty bool `mapstructure:"tty"` 120 Ulimits map[string]*UlimitsConfig 121 User string 122 Volumes []string 123 WorkingDir string `mapstructure:"working_dir"` 124 } 125 126 // ShellCommand is a string or list of string args 127 type ShellCommand []string 128 129 // StringList is a type for fields that can be a string or list of strings 130 type StringList []string 131 132 // StringOrNumberList is a type for fields that can be a list of strings or 133 // numbers 134 type StringOrNumberList []string 135 136 // MappingWithEquals is a mapping type that can be converted from a list of 137 // key=value strings 138 type MappingWithEquals map[string]string 139 140 // MappingWithColon is a mapping type that can be converted from a list of 141 // 'key: value' strings 142 type MappingWithColon map[string]string 143 144 // LoggingConfig the logging configuration for a service 145 type LoggingConfig struct { 146 Driver string 147 Options map[string]string 148 } 149 150 // DeployConfig the deployment configuration for a service 151 type DeployConfig struct { 152 Mode string 153 Replicas *uint64 154 Labels MappingWithEquals 155 UpdateConfig *UpdateConfig `mapstructure:"update_config"` 156 Resources Resources 157 RestartPolicy *RestartPolicy `mapstructure:"restart_policy"` 158 Placement Placement 159 } 160 161 // HealthCheckConfig the healthcheck configuration for a service 162 type HealthCheckConfig struct { 163 Test HealthCheckTest 164 Timeout string 165 Interval string 166 Retries *uint64 167 Disable bool 168 } 169 170 // HealthCheckTest is the command run to test the health of a service 171 type HealthCheckTest []string 172 173 // UpdateConfig the service update configuration 174 type UpdateConfig struct { 175 Parallelism *uint64 176 Delay time.Duration 177 FailureAction string `mapstructure:"failure_action"` 178 Monitor time.Duration 179 MaxFailureRatio float32 `mapstructure:"max_failure_ratio"` 180 } 181 182 // Resources the resource limits and reservations 183 type Resources struct { 184 Limits *Resource 185 Reservations *Resource 186 } 187 188 // Resource is a resource to be limited or reserved 189 type Resource struct { 190 // TODO: types to convert from units and ratios 191 NanoCPUs string `mapstructure:"cpus"` 192 MemoryBytes UnitBytes `mapstructure:"memory"` 193 } 194 195 // UnitBytes is the bytes type 196 type UnitBytes int64 197 198 // RestartPolicy the service restart policy 199 type RestartPolicy struct { 200 Condition string 201 Delay *time.Duration 202 MaxAttempts *uint64 `mapstructure:"max_attempts"` 203 Window *time.Duration 204 } 205 206 // Placement constraints for the service 207 type Placement struct { 208 Constraints []string 209 } 210 211 // ServiceNetworkConfig is the network configuration for a service 212 type ServiceNetworkConfig struct { 213 Aliases []string 214 Ipv4Address string `mapstructure:"ipv4_address"` 215 Ipv6Address string `mapstructure:"ipv6_address"` 216 } 217 218 // ServicePortConfig is the port configuration for a service 219 type ServicePortConfig struct { 220 Mode string 221 Target uint32 222 Published uint32 223 Protocol string 224 } 225 226 // ServiceSecretConfig is the secret configuration for a service 227 type ServiceSecretConfig struct { 228 Source string 229 Target string 230 UID string 231 GID string 232 Mode *uint32 233 } 234 235 // UlimitsConfig the ulimit configuration 236 type UlimitsConfig struct { 237 Single int 238 Soft int 239 Hard int 240 } 241 242 // NetworkConfig for a network 243 type NetworkConfig struct { 244 Driver string 245 DriverOpts map[string]string `mapstructure:"driver_opts"` 246 Ipam IPAMConfig 247 External External 248 Internal bool 249 Attachable bool 250 Labels MappingWithEquals 251 } 252 253 // IPAMConfig for a network 254 type IPAMConfig struct { 255 Driver string 256 Config []*IPAMPool 257 } 258 259 // IPAMPool for a network 260 type IPAMPool struct { 261 Subnet string 262 } 263 264 // VolumeConfig for a volume 265 type VolumeConfig struct { 266 Driver string 267 DriverOpts map[string]string `mapstructure:"driver_opts"` 268 External External 269 Labels MappingWithEquals 270 } 271 272 // External identifies a Volume or Network as a reference to a resource that is 273 // not managed, and should already exist. 274 type External struct { 275 Name string 276 External bool 277 } 278 279 // SecretConfig for a secret 280 type SecretConfig struct { 281 File string 282 External External 283 Labels MappingWithEquals 284 }