|
|
|
@ -102,7 +102,13 @@ type ServiceConfig struct {
|
|
|
|
|
CPUS float32 `mapstructure:"cpus" yaml:"cpus,omitempty" json:"cpus,omitempty"`
|
|
|
|
|
CPUSet string `mapstructure:"cpuset" yaml:"cpuset,omitempty" json:"cpuset,omitempty"`
|
|
|
|
|
CPUShares int64 `mapstructure:"cpu_shares" yaml:"cpu_shares,omitempty" json:"cpu_shares,omitempty"`
|
|
|
|
|
Command ShellCommand `yaml:",omitempty" json:"command,omitempty"`
|
|
|
|
|
|
|
|
|
|
// Command for the service containers.
|
|
|
|
|
// If set, overrides COMMAND from the image.
|
|
|
|
|
//
|
|
|
|
|
// Set to `[]` or `''` 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.
|
|
|
|
|
|
|
|
|
|
Configs []ServiceConfigObjConfig `yaml:",omitempty" json:"configs,omitempty"`
|
|
|
|
|
ContainerName string `mapstructure:"container_name" yaml:"container_name,omitempty" json:"container_name,omitempty"`
|
|
|
|
|
CredentialSpec *CredentialSpecConfig `mapstructure:"credential_spec" yaml:"credential_spec,omitempty" json:"credential_spec,omitempty"`
|
|
|
|
@ -115,7 +121,13 @@ type ServiceConfig struct {
|
|
|
|
|
DNSSearch StringList `mapstructure:"dns_search" yaml:"dns_search,omitempty" json:"dns_search,omitempty"`
|
|
|
|
|
Dockerfile string `yaml:"dockerfile,omitempty" json:"dockerfile,omitempty"`
|
|
|
|
|
DomainName string `mapstructure:"domainname" yaml:"domainname,omitempty" json:"domainname,omitempty"`
|
|
|
|
|
Entrypoint ShellCommand `yaml:",omitempty" json:"entrypoint,omitempty"`
|
|
|
|
|
|
|
|
|
|
// Entrypoint for the service containers.
|
|
|
|
|
// If set, overrides ENTRYPOINT from the image.
|
|
|
|
|
//
|
|
|
|
|
// Set to `[]` or `''` 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.
|
|
|
|
|
|
|
|
|
|
Environment MappingWithEquals `yaml:",omitempty" json:"environment,omitempty"`
|
|
|
|
|
EnvFile StringList `mapstructure:"env_file" yaml:"env_file,omitempty" json:"env_file,omitempty"`
|
|
|
|
|
Expose StringOrNumberList `yaml:",omitempty" json:"expose,omitempty"`
|
|
|
|
@ -306,6 +318,7 @@ type BuildConfig struct {
|
|
|
|
|
Target string `yaml:",omitempty" json:"target,omitempty"`
|
|
|
|
|
Secrets []ServiceSecretConfig `yaml:",omitempty" json:"secrets,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:"-"`
|
|
|
|
|
}
|
|
|
|
@ -338,9 +351,55 @@ type ThrottleDevice struct {
|
|
|
|
|
Extensions map[string]interface{} `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`
|
|
|
|
|
// is specified as a struct tag. Explicitly empty commands (i.e. `[]` or `''`)
|
|
|
|
|
// will serialize to an empty array (`[]`).
|
|
|
|
|
//
|
|
|
|
|
// When marshaled to JSON, the `omitempty` struct must NOT be specified.
|
|
|
|
|
// If the command field is nil, it will be serialized as `null`.
|
|
|
|
|
// Explicitly empty commands (i.e. `[]` or `''`) will serialize to an empty
|
|
|
|
|
// array (`[]`).
|
|
|
|
|
//
|
|
|
|
|
// The distinction between nil and explicitly empty is important to distinguish
|
|
|
|
|
// 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).
|
|
|
|
|
//
|
|
|
|
|
// The different semantics between YAML and JSON are due to limitations with
|
|
|
|
|
// JSON marshaling + `omitempty` in the Go stdlib, while gopkg.in/yaml.v2 gives
|
|
|
|
|
// us more flexibility via the yaml.IsZeroer interface.
|
|
|
|
|
//
|
|
|
|
|
// In the future, it might make sense to make fields of this type be
|
|
|
|
|
// `*ShellCommand` to avoid this situation, but that would constitute a
|
|
|
|
|
// breaking change.
|
|
|
|
|
type ShellCommand []string
|
|
|
|
|
|
|
|
|
|
// IsZero returns true if the slice is nil.
|
|
|
|
|
//
|
|
|
|
|
// Empty (but non-nil) slices are NOT considered zero values.
|
|
|
|
|
func (s ShellCommand) IsZero() bool {
|
|
|
|
|
// we do NOT want len(s) == 0, ONLY explicitly nil
|
|
|
|
|
return s == nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// MarshalYAML returns nil (which will be serialized as `null`) for nil slices
|
|
|
|
|
// and delegates to the standard marshaller behavior otherwise.
|
|
|
|
|
//
|
|
|
|
|
// NOTE: Typically the nil case here is not hit because IsZero has already
|
|
|
|
|
// short-circuited marshalling, but this ensures that the type serializes
|
|
|
|
|
// accurately if the `omitempty` struct tag is omitted/forgotten.
|
|
|
|
|
//
|
|
|
|
|
// A similar MarshalJSON() implementation is not needed because the Go stdlib
|
|
|
|
|
// already serializes nil slices to `null`, whereas gopkg.in/yaml.v2 by default
|
|
|
|
|
// serializes nil slices to `[]`.
|
|
|
|
|
func (s ShellCommand) MarshalYAML() (interface{}, error) {
|
|
|
|
|
if s == nil {
|
|
|
|
|
return nil, nil
|
|
|
|
|
}
|
|
|
|
|
return []string(s), nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// StringList is a type for fields that can be a string or list of strings
|
|
|
|
|
type StringList []string
|
|
|
|
|
|
|
|
|
|