@ -107,7 +107,7 @@ type ServiceConfig struct {
// Command for the service containers.
// Command for the service containers.
// If set, overrides COMMAND from the image.
// If set, overrides COMMAND from the image.
//
//
// Set to `[]` or `''` to clear the command from the image.
// Set to `[]` or an empty string to clear the command from the image.
Command ShellCommand ` yaml:",omitempty" json:"command" ` // NOTE: we can NOT omitempty for JSON! see ShellCommand type for details.
Command ShellCommand ` yaml:",omitempty" json:"command" ` // NOTE: we can NOT omitempty for JSON! see ShellCommand type for details.
Configs [ ] ServiceConfigObjConfig ` yaml:",omitempty" json:"configs,omitempty" `
Configs [ ] ServiceConfigObjConfig ` yaml:",omitempty" json:"configs,omitempty" `
@ -126,13 +126,13 @@ type ServiceConfig struct {
// Entrypoint for the service containers.
// Entrypoint for the service containers.
// If set, overrides ENTRYPOINT from the image.
// If set, overrides ENTRYPOINT from the image.
//
//
// Set to `[]` or `''` to clear the entrypoint from the image.
// Set to `[]` or an empty string to clear the entrypoint from the image.
Entrypoint ShellCommand ` yaml:"entrypoint,omitempty" json:"entrypoint" ` // NOTE: we can NOT omitempty for JSON! see ShellCommand type for details.
Entrypoint ShellCommand ` yaml:"entrypoint,omitempty" json:"entrypoint" ` // NOTE: we can NOT omitempty for JSON! see ShellCommand type for details.
Environment MappingWithEquals ` yaml:",omitempty" json:"environment,omitempty" `
Environment MappingWithEquals ` yaml:",omitempty" json:"environment,omitempty" `
EnvFile StringList ` mapstructure:"env_file" yaml:"env_file,omitempty" json:"env_file,omitempty" `
EnvFile StringList ` mapstructure:"env_file" yaml:"env_file,omitempty" json:"env_file,omitempty" `
Expose StringOrNumberList ` yaml:",omitempty" json:"expose,omitempty" `
Expose StringOrNumberList ` yaml:",omitempty" json:"expose,omitempty" `
Extends ExtendsConfig ` yaml:"extends,omitempty" json:"extends,omitempty" `
Extends * ExtendsConfig ` yaml:"extends,omitempty" json:"extends,omitempty" `
ExternalLinks [ ] string ` mapstructure:"external_links" yaml:"external_links,omitempty" json:"external_links,omitempty" `
ExternalLinks [ ] string ` mapstructure:"external_links" yaml:"external_links,omitempty" json:"external_links,omitempty" `
ExtraHosts HostsList ` mapstructure:"extra_hosts" yaml:"extra_hosts,omitempty" json:"extra_hosts,omitempty" `
ExtraHosts HostsList ` mapstructure:"extra_hosts" yaml:"extra_hosts,omitempty" json:"extra_hosts,omitempty" `
GroupAdd [ ] string ` mapstructure:"group_add" yaml:"group_add,omitempty" json:"group_add,omitempty" `
GroupAdd [ ] string ` mapstructure:"group_add" yaml:"group_add,omitempty" json:"group_add,omitempty" `
@ -186,7 +186,7 @@ type ServiceConfig struct {
VolumesFrom [ ] string ` mapstructure:"volumes_from" yaml:"volumes_from,omitempty" json:"volumes_from,omitempty" `
VolumesFrom [ ] string ` mapstructure:"volumes_from" yaml:"volumes_from,omitempty" json:"volumes_from,omitempty" `
WorkingDir string ` mapstructure:"working_dir" yaml:"working_dir,omitempty" json:"working_dir,omitempty" `
WorkingDir string ` mapstructure:"working_dir" yaml:"working_dir,omitempty" json:"working_dir,omitempty" `
Extensions map [ string ] interface { } ` yaml:",inline" json:"-"`
Extensions Extensions ` mapstructure:"#extensions" yaml:",inline" json:"-"`
}
}
// NetworksByPriority return the service networks IDs sorted according to Priority
// NetworksByPriority return the service networks IDs sorted according to Priority
@ -254,37 +254,26 @@ const (
NetworkModeContainerPrefix = ContainerPrefix
NetworkModeContainerPrefix = ContainerPrefix
)
)
// GetDependencies retrieve all services this service depends on
// GetDependencies retrieve s all services this service depends on
func ( s ServiceConfig ) GetDependencies ( ) [ ] string {
func ( s ServiceConfig ) GetDependencies ( ) [ ] string {
dependencies := make ( set )
var dependencies [ ] string
for dependency := range s . DependsOn {
for service := range s . DependsOn {
dependencies . append ( dependency )
dependencies = append ( dependencies , service )
}
for _ , link := range s . Links {
parts := strings . Split ( link , ":" )
if len ( parts ) == 2 {
dependencies . append ( parts [ 0 ] )
} else {
dependencies . append ( link )
}
}
if strings . HasPrefix ( s . NetworkMode , ServicePrefix ) {
dependencies . append ( s . NetworkMode [ len ( ServicePrefix ) : ] )
}
if strings . HasPrefix ( s . Ipc , ServicePrefix ) {
dependencies . append ( s . Ipc [ len ( ServicePrefix ) : ] )
}
if strings . HasPrefix ( s . Pid , ServicePrefix ) {
dependencies . append ( s . Pid [ len ( ServicePrefix ) : ] )
}
}
for _ , vol := range s . VolumesFrom {
return dependencies
if ! strings . HasPrefix ( s . Pid , ContainerPrefix ) {
}
spec := strings . Split ( vol , ":" )
dependencies . append ( spec [ 0 ] )
// GetDependents retrieves all services which depend on this service
func ( s ServiceConfig ) GetDependents ( p * Project ) [ ] string {
var dependent [ ] string
for _ , service := range p . Services {
for name := range service . DependsOn {
if name == s . Name {
dependent = append ( dependent , service . Name )
}
}
}
}
}
return dependent
return dependencies . toSlice ( )
}
}
type set map [ string ] struct { }
type set map [ string ] struct { }
@ -305,25 +294,27 @@ func (s set) toSlice() []string {
// BuildConfig is a type for build
// BuildConfig is a type for build
type BuildConfig struct {
type BuildConfig struct {
Context string ` yaml:",omitempty" json:"context,omitempty" `
Context string ` yaml:",omitempty" json:"context,omitempty" `
Dockerfile string ` yaml:",omitempty" json:"dockerfile,omitempty" `
Dockerfile string ` yaml:",omitempty" json:"dockerfile,omitempty" `
Args MappingWithEquals ` yaml:",omitempty" json:"args,omitempty" `
DockerfileInline string ` mapstructure:"dockerfile_inline,omitempty" yaml:"dockerfile_inline,omitempty" json:"dockerfile_inline,omitempty" `
SSH SSHConfig ` yaml:"ssh,omitempty" json:"ssh,omitempty" `
Args MappingWithEquals ` yaml:",omitempty" json:"args,omitempty" `
Labels Labels ` yaml:",omitempty" json:"labels,omitempty" `
SSH SSHConfig ` yaml:"ssh,omitempty" json:"ssh,omitempty" `
CacheFrom StringList ` mapstructure:"cache_from" yaml:"cache_from,omitempty" json:"cache_from,omitempty" `
Labels Labels ` yaml:",omitempty" json:"labels,omitempty" `
CacheTo StringList ` mapstructure:"cache_to" yaml:"cache_to,omitempty" json:"cache_to,omitempty" `
CacheFrom StringList ` mapstructure:"cache_from" yaml:"cache_from,omitempty" json:"cache_from,omitempty" `
NoCache bool ` mapstructure:"no_cache" yaml:"no_cache,omitempty" json:"no_cache,omitempty" `
CacheTo StringList ` mapstructure:"cache_to" yaml:"cache_to,omitempty" json:"cache_to,omitempty" `
Pull bool ` mapstructure:"pull" yaml:"pull,omitempty" json:"pull,omitempty" `
NoCache bool ` mapstructure:"no_cache" yaml:"no_cache,omitempty" json:"no_cache,omitempty" `
ExtraHosts HostsList ` mapstructure:"extra_hosts" yaml:"extra_hosts,omitempty" json:"extra_hosts,omitempty" `
AdditionalContexts Mapping ` mapstructure:"additional_contexts" yaml:"additional_contexts,omitempty" json:"additional_contexts,omitempty" `
Isolation string ` yaml:",omitempty" json:"isolation,omitempty" `
Pull bool ` mapstructure:"pull" yaml:"pull,omitempty" json:"pull,omitempty" `
Network string ` yaml:",omitempty" json:"network,omitempty" `
ExtraHosts HostsList ` mapstructure:"extra_hosts" yaml:"extra_hosts,omitempty" json:"extra_hosts,omitempty" `
Target string ` yaml:",omitempty" json:"target,omitempty" `
Isolation string ` yaml:",omitempty" json:"isolation,omitempty" `
Secrets [ ] ServiceSecretConfig ` yaml:",omitempty" json:"secrets,omitempty" `
Network string ` yaml:",omitempty" json:"network,omitempty" `
Tags StringList ` mapstructure:"tags" yaml:"tags,omitempty" json:"tags,omitempty" `
Target string ` yaml:",omitempty" json:"target,omitempty" `
Platforms StringList ` mapstructure:"platforms" yaml:"platforms,omitempty" json:"platforms,omitempty" `
Secrets [ ] ServiceSecretConfig ` yaml:",omitempty" json:"secrets,omitempty" `
Privileged bool ` yaml:",omitempty" json:"privileged,omitempty" `
Tags StringList ` mapstructure:"tags" yaml:"tags,omitempty" json:"tags,omitempty" `
Platforms StringList ` mapstructure:"platforms" yaml:"platforms,omitempty" json:"platforms,omitempty" `
Extensions map [ string ] interface { } ` yaml:",inline" json:"-" `
Privileged bool ` yaml:",omitempty" json:"privileged,omitempty" `
Extensions Extensions ` mapstructure:"#extensions" yaml:",inline" json:"-" `
}
}
// BlkioConfig define blkio config
// BlkioConfig define blkio config
@ -335,7 +326,7 @@ type BlkioConfig struct {
DeviceWriteBps [ ] ThrottleDevice ` mapstructure:"device_write_bps" yaml:",omitempty" json:"device_write_bps,omitempty" `
DeviceWriteBps [ ] ThrottleDevice ` mapstructure:"device_write_bps" yaml:",omitempty" json:"device_write_bps,omitempty" `
DeviceWriteIOps [ ] ThrottleDevice ` mapstructure:"device_write_iops" yaml:",omitempty" json:"device_write_iops,omitempty" `
DeviceWriteIOps [ ] ThrottleDevice ` mapstructure:"device_write_iops" yaml:",omitempty" json:"device_write_iops,omitempty" `
Extensions map [ string ] interface { } ` yaml:",inline" json:"-"`
Extensions Extensions ` mapstructure:"#extensions" yaml:",inline" json:"-"`
}
}
// WeightDevice is a structure that holds device:weight pair
// WeightDevice is a structure that holds device:weight pair
@ -343,34 +334,34 @@ type WeightDevice struct {
Path string
Path string
Weight uint16
Weight uint16
Extensions map [ string ] interface { } ` yaml:",inline" json:"-"`
Extensions Extensions ` mapstructure:"#extensions" yaml:",inline" json:"-"`
}
}
// ThrottleDevice is a structure that holds device:rate_per_second pair
// ThrottleDevice is a structure that holds device:rate_per_second pair
type ThrottleDevice struct {
type ThrottleDevice struct {
Path string
Path string
Rate uint64
Rate UnitBytes
Extensions map [ string ] interface { } ` yaml:",inline" json:"-"`
Extensions Extensions ` mapstructure:"#extensions" yaml:",inline" json:"-"`
}
}
// ShellCommand is a string or list of string args.
// ShellCommand is a string or list of string args.
//
//
// When marshaled to YAML, nil command fields will be omitted if `omitempty`
// When marshaled to YAML, nil command fields will be omitted if `omitempty`
// is specified as a struct tag. Explicitly empty commands (i.e. `[]` or `''`)
// is specified as a struct tag. Explicitly empty commands (i.e. `[]` or
// will serialize to an empty array (`[]`).
// empty string will serialize to an empty array (`[]`).
//
//
// When marshaled to JSON, the `omitempty` struct must NOT be specified.
// When marshaled to JSON, the `omitempty` struct must NOT be specified.
// If the command field is nil, it will be serialized as `null`.
// If the command field is nil, it will be serialized as `null`.
// Explicitly empty commands (i.e. `[]` or `''`) will serialize to an empty
// Explicitly empty commands (i.e. `[]` or empty string) will serialize to
// a rray (`[]`).
// a n empty a rray (`[]`).
//
//
// The distinction between nil and explicitly empty is important to distinguish
// The distinction between nil and explicitly empty is important to distinguish
// between an unset value and a provided, but empty, value, which should be
// between an unset value and a provided, but empty, value, which should be
// preserved so that it can override any base value (e.g. container entrypoint).
// preserved so that it can override any base value (e.g. container entrypoint).
//
//
// The different semantics between YAML and JSON are due to limitations with
// The different semantics between YAML and JSON are due to limitations with
// JSON marshaling + `omitempty` in the Go stdlib, while gopkg.in/yaml.v 2 gives
// JSON marshaling + `omitempty` in the Go stdlib, while gopkg.in/yaml.v 3 gives
// us more flexibility via the yaml.IsZeroer interface.
// us more flexibility via the yaml.IsZeroer interface.
//
//
// In the future, it might make sense to make fields of this type be
// In the future, it might make sense to make fields of this type be
@ -394,7 +385,7 @@ func (s ShellCommand) IsZero() bool {
// accurately if the `omitempty` struct tag is omitted/forgotten.
// accurately if the `omitempty` struct tag is omitted/forgotten.
//
//
// A similar MarshalJSON() implementation is not needed because the Go stdlib
// A similar MarshalJSON() implementation is not needed because the Go stdlib
// already serializes nil slices to `null`, whereas gopkg.in/yaml.v 2 by default
// already serializes nil slices to `null`, whereas gopkg.in/yaml.v 3 by default
// serializes nil slices to `[]`.
// serializes nil slices to `[]`.
func ( s ShellCommand ) MarshalYAML ( ) ( interface { } , error ) {
func ( s ShellCommand ) MarshalYAML ( ) ( interface { } , error ) {
if s == nil {
if s == nil {
@ -574,7 +565,7 @@ type LoggingConfig struct {
Driver string ` yaml:",omitempty" json:"driver,omitempty" `
Driver string ` yaml:",omitempty" json:"driver,omitempty" `
Options map [ string ] string ` yaml:",omitempty" json:"options,omitempty" `
Options map [ string ] string ` yaml:",omitempty" json:"options,omitempty" `
Extensions map [ string ] interface { } ` yaml:",inline" json:"-"`
Extensions Extensions ` mapstructure:"#extensions" yaml:",inline" json:"-"`
}
}
// DeployConfig the deployment configuration for a service
// DeployConfig the deployment configuration for a service
@ -589,7 +580,7 @@ type DeployConfig struct {
Placement Placement ` yaml:",omitempty" json:"placement,omitempty" `
Placement Placement ` yaml:",omitempty" json:"placement,omitempty" `
EndpointMode string ` mapstructure:"endpoint_mode" yaml:"endpoint_mode,omitempty" json:"endpoint_mode,omitempty" `
EndpointMode string ` mapstructure:"endpoint_mode" yaml:"endpoint_mode,omitempty" json:"endpoint_mode,omitempty" `
Extensions map [ string ] interface { } ` yaml:",inline" json:"-"`
Extensions Extensions ` mapstructure:"#extensions" yaml:",inline" json:"-"`
}
}
// HealthCheckConfig the healthcheck configuration for a service
// HealthCheckConfig the healthcheck configuration for a service
@ -601,7 +592,7 @@ type HealthCheckConfig struct {
StartPeriod * Duration ` mapstructure:"start_period" yaml:"start_period,omitempty" json:"start_period,omitempty" `
StartPeriod * Duration ` mapstructure:"start_period" yaml:"start_period,omitempty" json:"start_period,omitempty" `
Disable bool ` yaml:",omitempty" json:"disable,omitempty" `
Disable bool ` yaml:",omitempty" json:"disable,omitempty" `
Extensions map [ string ] interface { } ` yaml:",inline" json:"-"`
Extensions Extensions ` mapstructure:"#extensions" yaml:",inline" json:"-"`
}
}
// HealthCheckTest is the command run to test the health of a service
// HealthCheckTest is the command run to test the health of a service
@ -616,7 +607,7 @@ type UpdateConfig struct {
MaxFailureRatio float32 ` mapstructure:"max_failure_ratio" yaml:"max_failure_ratio,omitempty" json:"max_failure_ratio,omitempty" `
MaxFailureRatio float32 ` mapstructure:"max_failure_ratio" yaml:"max_failure_ratio,omitempty" json:"max_failure_ratio,omitempty" `
Order string ` yaml:",omitempty" json:"order,omitempty" `
Order string ` yaml:",omitempty" json:"order,omitempty" `
Extensions map [ string ] interface { } ` yaml:",inline" json:"-"`
Extensions Extensions ` mapstructure:"#extensions" yaml:",inline" json:"-"`
}
}
// Resources the resource limits and reservations
// Resources the resource limits and reservations
@ -624,7 +615,7 @@ type Resources struct {
Limits * Resource ` yaml:",omitempty" json:"limits,omitempty" `
Limits * Resource ` yaml:",omitempty" json:"limits,omitempty" `
Reservations * Resource ` yaml:",omitempty" json:"reservations,omitempty" `
Reservations * Resource ` yaml:",omitempty" json:"reservations,omitempty" `
Extensions map [ string ] interface { } ` yaml:",inline" json:"-"`
Extensions Extensions ` mapstructure:"#extensions" yaml:",inline" json:"-"`
}
}
// Resource is a resource to be limited or reserved
// Resource is a resource to be limited or reserved
@ -636,7 +627,7 @@ type Resource struct {
Devices [ ] DeviceRequest ` mapstructure:"devices" yaml:"devices,omitempty" json:"devices,omitempty" `
Devices [ ] DeviceRequest ` mapstructure:"devices" yaml:"devices,omitempty" json:"devices,omitempty" `
GenericResources [ ] GenericResource ` mapstructure:"generic_resources" yaml:"generic_resources,omitempty" json:"generic_resources,omitempty" `
GenericResources [ ] GenericResource ` mapstructure:"generic_resources" yaml:"generic_resources,omitempty" json:"generic_resources,omitempty" `
Extensions map [ string ] interface { } ` yaml:",inline" json:"-"`
Extensions Extensions ` mapstructure:"#extensions" yaml:",inline" json:"-"`
}
}
type DeviceRequest struct {
type DeviceRequest struct {
@ -651,7 +642,7 @@ type DeviceRequest struct {
type GenericResource struct {
type GenericResource struct {
DiscreteResourceSpec * DiscreteGenericResource ` mapstructure:"discrete_resource_spec" yaml:"discrete_resource_spec,omitempty" json:"discrete_resource_spec,omitempty" `
DiscreteResourceSpec * DiscreteGenericResource ` mapstructure:"discrete_resource_spec" yaml:"discrete_resource_spec,omitempty" json:"discrete_resource_spec,omitempty" `
Extensions map [ string ] interface { } ` yaml:",inline" json:"-"`
Extensions Extensions ` mapstructure:"#extensions" yaml:",inline" json:"-"`
}
}
// DiscreteGenericResource represents a "user defined" resource which is defined
// DiscreteGenericResource represents a "user defined" resource which is defined
@ -662,7 +653,7 @@ type DiscreteGenericResource struct {
Kind string ` json:"kind" `
Kind string ` json:"kind" `
Value int64 ` json:"value" `
Value int64 ` json:"value" `
Extensions map [ string ] interface { } ` yaml:",inline" json:"-"`
Extensions Extensions ` mapstructure:"#extensions" yaml:",inline" json:"-"`
}
}
// UnitBytes is the bytes type
// UnitBytes is the bytes type
@ -685,7 +676,7 @@ type RestartPolicy struct {
MaxAttempts * uint64 ` mapstructure:"max_attempts" yaml:"max_attempts,omitempty" json:"max_attempts,omitempty" `
MaxAttempts * uint64 ` mapstructure:"max_attempts" yaml:"max_attempts,omitempty" json:"max_attempts,omitempty" `
Window * Duration ` yaml:",omitempty" json:"window,omitempty" `
Window * Duration ` yaml:",omitempty" json:"window,omitempty" `
Extensions map [ string ] interface { } ` yaml:",inline" json:"-"`
Extensions Extensions ` mapstructure:"#extensions" yaml:",inline" json:"-"`
}
}
// Placement constraints for the service
// Placement constraints for the service
@ -694,14 +685,14 @@ type Placement struct {
Preferences [ ] PlacementPreferences ` yaml:",omitempty" json:"preferences,omitempty" `
Preferences [ ] PlacementPreferences ` yaml:",omitempty" json:"preferences,omitempty" `
MaxReplicas uint64 ` mapstructure:"max_replicas_per_node" yaml:"max_replicas_per_node,omitempty" json:"max_replicas_per_node,omitempty" `
MaxReplicas uint64 ` mapstructure:"max_replicas_per_node" yaml:"max_replicas_per_node,omitempty" json:"max_replicas_per_node,omitempty" `
Extensions map [ string ] interface { } ` yaml:",inline" json:"-"`
Extensions Extensions ` mapstructure:"#extensions" yaml:",inline" json:"-"`
}
}
// PlacementPreferences is the preferences for a service placement
// PlacementPreferences is the preferences for a service placement
type PlacementPreferences struct {
type PlacementPreferences struct {
Spread string ` yaml:",omitempty" json:"spread,omitempty" `
Spread string ` yaml:",omitempty" json:"spread,omitempty" `
Extensions map [ string ] interface { } ` yaml:",inline" json:"-"`
Extensions Extensions ` mapstructure:"#extensions" yaml:",inline" json:"-"`
}
}
// ServiceNetworkConfig is the network configuration for a service
// ServiceNetworkConfig is the network configuration for a service
@ -712,7 +703,7 @@ type ServiceNetworkConfig struct {
Ipv6Address string ` mapstructure:"ipv6_address" yaml:"ipv6_address,omitempty" json:"ipv6_address,omitempty" `
Ipv6Address string ` mapstructure:"ipv6_address" yaml:"ipv6_address,omitempty" json:"ipv6_address,omitempty" `
LinkLocalIPs [ ] string ` mapstructure:"link_local_ips" yaml:"link_local_ips,omitempty" json:"link_local_ips,omitempty" `
LinkLocalIPs [ ] string ` mapstructure:"link_local_ips" yaml:"link_local_ips,omitempty" json:"link_local_ips,omitempty" `
Extensions map [ string ] interface { } ` yaml:",inline" json:"-"`
Extensions Extensions ` mapstructure:"#extensions" yaml:",inline" json:"-"`
}
}
// ServicePortConfig is the port configuration for a service
// ServicePortConfig is the port configuration for a service
@ -723,7 +714,7 @@ type ServicePortConfig struct {
Published string ` yaml:",omitempty" json:"published,omitempty" `
Published string ` yaml:",omitempty" json:"published,omitempty" `
Protocol string ` yaml:",omitempty" json:"protocol,omitempty" `
Protocol string ` yaml:",omitempty" json:"protocol,omitempty" `
Extensions map [ string ] interface { } ` yaml:",inline" json:"-"`
Extensions Extensions ` mapstructure:"#extensions" yaml:",inline" json:"-"`
}
}
// ParsePortConfig parse short syntax for service port configuration
// ParsePortConfig parse short syntax for service port configuration
@ -776,7 +767,7 @@ type ServiceVolumeConfig struct {
Volume * ServiceVolumeVolume ` yaml:",omitempty" json:"volume,omitempty" `
Volume * ServiceVolumeVolume ` yaml:",omitempty" json:"volume,omitempty" `
Tmpfs * ServiceVolumeTmpfs ` yaml:",omitempty" json:"tmpfs,omitempty" `
Tmpfs * ServiceVolumeTmpfs ` yaml:",omitempty" json:"tmpfs,omitempty" `
Extensions map [ string ] interface { } ` yaml:",inline" json:"-"`
Extensions Extensions ` mapstructure:"#extensions" yaml:",inline" json:"-"`
}
}
// String render ServiceVolumeConfig as a volume string, one can parse back using loader.ParseVolume
// String render ServiceVolumeConfig as a volume string, one can parse back using loader.ParseVolume
@ -820,7 +811,7 @@ type ServiceVolumeBind struct {
Propagation string ` yaml:",omitempty" json:"propagation,omitempty" `
Propagation string ` yaml:",omitempty" json:"propagation,omitempty" `
CreateHostPath bool ` mapstructure:"create_host_path" yaml:"create_host_path,omitempty" json:"create_host_path,omitempty" `
CreateHostPath bool ` mapstructure:"create_host_path" yaml:"create_host_path,omitempty" json:"create_host_path,omitempty" `
Extensions map [ string ] interface { } ` yaml:",inline" json:"-"`
Extensions Extensions ` mapstructure:"#extensions" yaml:",inline" json:"-"`
}
}
// SELinux represents the SELinux re-labeling options.
// SELinux represents the SELinux re-labeling options.
@ -851,7 +842,7 @@ const (
type ServiceVolumeVolume struct {
type ServiceVolumeVolume struct {
NoCopy bool ` mapstructure:"nocopy" yaml:"nocopy,omitempty" json:"nocopy,omitempty" `
NoCopy bool ` mapstructure:"nocopy" yaml:"nocopy,omitempty" json:"nocopy,omitempty" `
Extensions map [ string ] interface { } ` yaml:",inline" json:"-"`
Extensions Extensions ` mapstructure:"#extensions" yaml:",inline" json:"-"`
}
}
// ServiceVolumeTmpfs are options for a service volume of type tmpfs
// ServiceVolumeTmpfs are options for a service volume of type tmpfs
@ -860,7 +851,7 @@ type ServiceVolumeTmpfs struct {
Mode uint32 ` yaml:",omitempty" json:"mode,omitempty" `
Mode uint32 ` yaml:",omitempty" json:"mode,omitempty" `
Extensions map [ string ] interface { } ` yaml:",inline" json:"-"`
Extensions Extensions ` mapstructure:"#extensions" yaml:",inline" json:"-"`
}
}
// FileReferenceConfig for a reference to a swarm file object
// FileReferenceConfig for a reference to a swarm file object
@ -871,7 +862,7 @@ type FileReferenceConfig struct {
GID string ` yaml:",omitempty" json:"gid,omitempty" `
GID string ` yaml:",omitempty" json:"gid,omitempty" `
Mode * uint32 ` yaml:",omitempty" json:"mode,omitempty" `
Mode * uint32 ` yaml:",omitempty" json:"mode,omitempty" `
Extensions map [ string ] interface { } ` yaml:",inline" json:"-"`
Extensions Extensions ` mapstructure:"#extensions" yaml:",inline" json:"-"`
}
}
// ServiceConfigObjConfig is the config obj configuration for a service
// ServiceConfigObjConfig is the config obj configuration for a service
@ -886,7 +877,7 @@ type UlimitsConfig struct {
Soft int ` yaml:",omitempty" json:"soft,omitempty" `
Soft int ` yaml:",omitempty" json:"soft,omitempty" `
Hard int ` yaml:",omitempty" json:"hard,omitempty" `
Hard int ` yaml:",omitempty" json:"hard,omitempty" `
Extensions map [ string ] interface { } ` yaml:",inline" json:"-"`
Extensions Extensions ` mapstructure:"#extensions" yaml:",inline" json:"-"`
}
}
// MarshalYAML makes UlimitsConfig implement yaml.Marshaller
// MarshalYAML makes UlimitsConfig implement yaml.Marshaller
@ -894,7 +885,13 @@ func (u *UlimitsConfig) MarshalYAML() (interface{}, error) {
if u . Single != 0 {
if u . Single != 0 {
return u . Single , nil
return u . Single , nil
}
}
return u , nil
return struct {
Soft int
Hard int
} {
Soft : u . Soft ,
Hard : u . Hard ,
} , nil
}
}
// MarshalJSON makes UlimitsConfig implement json.Marshaller
// MarshalJSON makes UlimitsConfig implement json.Marshaller
@ -908,23 +905,23 @@ func (u *UlimitsConfig) MarshalJSON() ([]byte, error) {
// NetworkConfig for a network
// NetworkConfig for a network
type NetworkConfig struct {
type NetworkConfig struct {
Name string ` yaml:",omitempty" json:"name,omitempty" `
Name string ` yaml:",omitempty" json:"name,omitempty" `
Driver string ` yaml:",omitempty" json:"driver,omitempty" `
Driver string ` yaml:",omitempty" json:"driver,omitempty" `
DriverOpts map [ string ] string ` mapstructure:"driver_opts" yaml:"driver_opts,omitempty" json:"driver_opts,omitempty" `
DriverOpts map [ string ] string ` mapstructure:"driver_opts" yaml:"driver_opts,omitempty" json:"driver_opts,omitempty" `
Ipam IPAMConfig ` yaml:",omitempty" json:"ipam,omitempty" `
Ipam IPAMConfig ` yaml:",omitempty" json:"ipam,omitempty" `
External External ` yaml:",omitempty" json:"external,omitempty" `
External External ` yaml:",omitempty" json:"external,omitempty" `
Internal bool ` yaml:",omitempty" json:"internal,omitempty" `
Internal bool ` yaml:",omitempty" json:"internal,omitempty" `
Attachable bool ` yaml:",omitempty" json:"attachable,omitempty" `
Attachable bool ` yaml:",omitempty" json:"attachable,omitempty" `
Labels Labels ` yaml:",omitempty" json:"labels,omitempty" `
Labels Labels ` yaml:",omitempty" json:"labels,omitempty" `
EnableIPv6 bool ` mapstructure:"enable_ipv6" yaml:"enable_ipv6,omitempty" json:"enable_ipv6,omitempty" `
EnableIPv6 bool ` mapstructure:"enable_ipv6" yaml:"enable_ipv6,omitempty" json:"enable_ipv6,omitempty" `
Extensions map [ string ] interface { } ` yaml:",inline" json:"-"`
Extensions Extensions ` mapstructure:"#extensions" yaml:",inline" json:"-"`
}
}
// IPAMConfig for a network
// IPAMConfig for a network
type IPAMConfig struct {
type IPAMConfig struct {
Driver string ` yaml:",omitempty" json:"driver,omitempty" `
Driver string ` yaml:",omitempty" json:"driver,omitempty" `
Config [ ] * IPAMPool ` yaml:",omitempty" json:"config,omitempty" `
Config [ ] * IPAMPool ` yaml:",omitempty" json:"config,omitempty" `
Extensions map [ string ] interface { } ` yaml:",inline" json:"-"`
Extensions Extensions ` mapstructure:"#extensions" yaml:",inline" json:"-"`
}
}
// IPAMPool for a network
// IPAMPool for a network
@ -938,21 +935,21 @@ type IPAMPool struct {
// VolumeConfig for a volume
// VolumeConfig for a volume
type VolumeConfig struct {
type VolumeConfig struct {
Name string ` yaml:",omitempty" json:"name,omitempty" `
Name string ` yaml:",omitempty" json:"name,omitempty" `
Driver string ` yaml:",omitempty" json:"driver,omitempty" `
Driver string ` yaml:",omitempty" json:"driver,omitempty" `
DriverOpts map [ string ] string ` mapstructure:"driver_opts" yaml:"driver_opts,omitempty" json:"driver_opts,omitempty" `
DriverOpts map [ string ] string ` mapstructure:"driver_opts" yaml:"driver_opts,omitempty" json:"driver_opts,omitempty" `
External External ` yaml:",omitempty" json:"external,omitempty" `
External External ` yaml:",omitempty" json:"external,omitempty" `
Labels Labels ` yaml:",omitempty" json:"labels,omitempty" `
Labels Labels ` yaml:",omitempty" json:"labels,omitempty" `
Extensions map [ string ] interface { } ` yaml:",inline" json:"-"`
Extensions Extensions ` mapstructure:"#extensions" yaml:",inline" json:"-"`
}
}
// External identifies a Volume or Network as a reference to a resource that is
// External identifies a Volume or Network as a reference to a resource that is
// not managed, and should already exist.
// not managed, and should already exist.
// External.name is deprecated and replaced by Volume.name
// External.name is deprecated and replaced by Volume.name
type External struct {
type External struct {
Name string ` yaml:",omitempty" json:"name,omitempty" `
Name string ` yaml:",omitempty" json:"name,omitempty" `
External bool ` yaml:",omitempty" json:"external,omitempty" `
External bool ` yaml:",omitempty" json:"external,omitempty" `
Extensions map [ string ] interface { } ` yaml:",inline" json:"-"`
Extensions Extensions ` mapstructure:"#extensions" yaml:",inline" json:"-"`
}
}
// MarshalYAML makes External implement yaml.Marshaller
// MarshalYAML makes External implement yaml.Marshaller
@ -973,23 +970,23 @@ func (e External) MarshalJSON() ([]byte, error) {
// CredentialSpecConfig for credential spec on Windows
// CredentialSpecConfig for credential spec on Windows
type CredentialSpecConfig struct {
type CredentialSpecConfig struct {
Config string ` yaml:",omitempty" json:"config,omitempty" ` // Config was added in API v1.40
Config string ` yaml:",omitempty" json:"config,omitempty" ` // Config was added in API v1.40
File string ` yaml:",omitempty" json:"file,omitempty" `
File string ` yaml:",omitempty" json:"file,omitempty" `
Registry string ` yaml:",omitempty" json:"registry,omitempty" `
Registry string ` yaml:",omitempty" json:"registry,omitempty" `
Extensions map [ string ] interface { } ` yaml:",inline" json:"-"`
Extensions Extensions ` mapstructure:"#extensions" yaml:",inline" json:"-"`
}
}
// FileObjectConfig is a config type for a file used by a service
// FileObjectConfig is a config type for a file used by a service
type FileObjectConfig struct {
type FileObjectConfig struct {
Name string ` yaml:",omitempty" json:"name,omitempty" `
Name string ` yaml:",omitempty" json:"name,omitempty" `
File string ` yaml:",omitempty" json:"file,omitempty" `
File string ` yaml:",omitempty" json:"file,omitempty" `
Environment string ` yaml:",omitempty" json:"environment,omitempty" `
Environment string ` yaml:",omitempty" json:"environment,omitempty" `
External External ` yaml:",omitempty" json:"external,omitempty" `
External External ` yaml:",omitempty" json:"external,omitempty" `
Labels Labels ` yaml:",omitempty" json:"labels,omitempty" `
Labels Labels ` yaml:",omitempty" json:"labels,omitempty" `
Driver string ` yaml:",omitempty" json:"driver,omitempty" `
Driver string ` yaml:",omitempty" json:"driver,omitempty" `
DriverOpts map [ string ] string ` mapstructure:"driver_opts" yaml:"driver_opts,omitempty" json:"driver_opts,omitempty" `
DriverOpts map [ string ] string ` mapstructure:"driver_opts" yaml:"driver_opts,omitempty" json:"driver_opts,omitempty" `
TemplateDriver string ` mapstructure:"template_driver" yaml:"template_driver,omitempty" json:"template_driver,omitempty" `
TemplateDriver string ` mapstructure:"template_driver" yaml:"template_driver,omitempty" json:"template_driver,omitempty" `
Extensions map [ string ] interface { } ` yaml:",inline" json:"-"`
Extensions Extensions ` mapstructure:"#extensions" yaml:",inline" json:"-"`
}
}
const (
const (
@ -1006,11 +1003,15 @@ const (
type DependsOnConfig map [ string ] ServiceDependency
type DependsOnConfig map [ string ] ServiceDependency
type ServiceDependency struct {
type ServiceDependency struct {
Condition string ` yaml:",omitempty" json:"condition,omitempty" `
Condition string ` yaml:",omitempty" json:"condition,omitempty" `
Extensions map [ string ] interface { } ` yaml:",inline" json:"-" `
Restart bool ` yaml:",omitempty" json:"restart,omitempty" `
Extensions Extensions ` mapstructure:"#extensions" yaml:",inline" json:"-" `
}
}
type ExtendsConfig MappingWithEquals
type ExtendsConfig struct {
File string ` yaml:",omitempty" json:"file,omitempty" `
Service string ` yaml:",omitempty" json:"service,omitempty" `
}
// SecretConfig for a secret
// SecretConfig for a secret
type SecretConfig FileObjectConfig
type SecretConfig FileObjectConfig