Documentation
      ¶
    
    
  
    
  
    Index ¶
- Constants
 - func IgnoreDependencies(options *withServicesOptions)
 - func IncludeDependencies(options *withServicesOptions)
 - func IncludeDependents(options *withServicesOptions)
 - func WithSecretContent(o *marshallOptions)
 - type BlkioConfig
 - type BuildConfig
 - type Config
 - type ConfigDetails
 - type ConfigFile
 - type ConfigObjConfig
 - type Configs
 - type CredentialSpecConfig
 - type DependencyOption
 - type DependsOnConfig
 - type DeployConfig
 - type DevelopConfig
 - type DeviceCount
 - type DeviceMapping
 - type DeviceRequest
 - type DiscreteGenericResource
 - type Duration
 - type EnvFile
 - type ExtendsConfig
 - type Extensions
 - type External
 - type FileMode
 - type FileObjectConfig
 - type FileReferenceConfig
 - type GenericResource
 - type HealthCheckConfig
 - type HealthCheckTest
 - type HostsList
 - type IPAMConfig
 - type IPAMPool
 - type IncludeConfig
 - type Labels
 - type LoggingConfig
 - type Mapping
 - type MappingWithColon
 - type MappingWithEquals
 - func (m *MappingWithEquals) DecodeMapstructure(value interface{}) error
 - func (m MappingWithEquals) OverrideBy(other MappingWithEquals) MappingWithEquals
 - func (m MappingWithEquals) RemoveEmpty() MappingWithEquals
 - func (m MappingWithEquals) Resolve(lookupFn func(string) (string, bool)) MappingWithEquals
 - func (m MappingWithEquals) ToMapping() Mapping
 
- type ModelConfig
 - type Models
 - type MultiOptions
 - type NanoCPUs
 - type NetworkConfig
 - type Networks
 - type Options
 - type Placement
 - type PlacementPreferences
 - type Project
 - func (p *Project) AllServices() Services
 - func (p *Project) CheckContainerNameUnicity() error
 - func (p *Project) ConfigNames() []string
 - func (p *Project) DisabledServiceNames() []string
 - func (p *Project) ForEachService(names []string, fn ServiceFunc, options ...DependencyOption) error
 - func (p *Project) GetDependentsForService(s ServiceConfig, filter ...func(ServiceDependency) bool) []string
 - func (p Project) GetDisabledService(name string) (ServiceConfig, error)
 - func (p *Project) GetService(name string) (ServiceConfig, error)
 - func (p *Project) GetServices(names ...string) (Services, error)
 - func (p *Project) MarshalJSON(options ...func(*marshallOptions)) ([]byte, error)
 - func (p *Project) MarshalYAML(options ...func(*marshallOptions)) ([]byte, error)
 - func (p *Project) ModelNames() []string
 - func (p *Project) NetworkNames() []string
 - func (p *Project) RelativePath(path string) string
 - func (p *Project) SecretNames() []string
 - func (p *Project) ServiceNames() []string
 - func (p *Project) ServicesWithBuild() []string
 - func (p *Project) ServicesWithCapabilities() ([]string, []string, []string)
 - func (p *Project) ServicesWithDependsOn() []string
 - func (p *Project) ServicesWithExtends() []string
 - func (p *Project) ServicesWithModels() []string
 - func (p *Project) VolumeNames() []string
 - func (p *Project) WithImagesResolved(resolver func(named reference.Named) (godigest.Digest, error)) (*Project, error)
 - func (p *Project) WithProfiles(profiles []string) (*Project, error)
 - func (p *Project) WithSelectedServices(names []string, options ...DependencyOption) (*Project, error)
 - func (p *Project) WithServicesDisabled(names ...string) *Project
 - func (p *Project) WithServicesEnabled(names ...string) (*Project, error)
 - func (p Project) WithServicesEnvironmentResolved(discardEnvFiles bool) (*Project, error)
 - func (p Project) WithServicesLabelsResolved(discardLabelFiles bool) (*Project, error)
 - func (p *Project) WithServicesTransform(fn func(name string, s ServiceConfig) (ServiceConfig, error)) (*Project, error)
 - func (p *Project) WithoutUnnecessaryResources() *Project
 
- type Resource
 - type Resources
 - type RestartPolicy
 - type SSHConfig
 - type SSHKey
 - type SecretConfig
 - type Secrets
 - type ServiceConfig
 - func (s ServiceConfig) GetDependencies() []string
 - func (s ServiceConfig) GetDependents(p *Project) []string
 - func (s ServiceConfig) GetPullPolicy() (string, time.Duration, error)
 - func (s *ServiceConfig) GetScale() int
 - func (s ServiceConfig) HasProfile(profiles []string) bool
 - func (s ServiceConfig) MarshalYAML() (interface{}, error)
 - func (s *ServiceConfig) NetworksByPriority() []string
 - func (s *ServiceConfig) SetScale(scale int)
 
- type ServiceConfigObjConfig
 - type ServiceDependency
 - type ServiceFunc
 - type ServiceHook
 - type ServiceModelConfig
 - type ServiceNetworkConfig
 - type ServicePortConfig
 - type ServiceProviderConfig
 - type ServiceSecretConfig
 - type ServiceVolumeBind
 - type ServiceVolumeConfig
 - type ServiceVolumeImage
 - type ServiceVolumeTmpfs
 - type ServiceVolumeVolume
 - type Services
 - type ShellCommand
 - type StringList
 - type StringOrNumberList
 - type ThrottleDevice
 - type Trigger
 - type UlimitsConfig
 - type UnitBytes
 - type UpdateConfig
 - type VolumeConfig
 - type Volumes
 - type WatchAction
 - type WeightDevice
 
Constants ¶
const ( // PullPolicyAlways always pull images PullPolicyAlways = "always" // PullPolicyNever never pull images PullPolicyNever = "never" // PullPolicyIfNotPresent pull missing images PullPolicyIfNotPresent = "if_not_present" // PullPolicyMissing pull missing images PullPolicyMissing = "missing" // PullPolicyBuild force building images PullPolicyBuild = "build" // PullPolicyRefresh checks if image needs to be updated PullPolicyRefresh = "refresh" )
const ( // RestartPolicyAlways always restart the container if it stops RestartPolicyAlways = "always" // RestartPolicyOnFailure restart the container if it exits due to an error RestartPolicyOnFailure = "on-failure" // RestartPolicyNo do not automatically restart the container RestartPolicyNo = "no" // RestartPolicyUnlessStopped always restart the container unless the container is stopped (manually or otherwise) RestartPolicyUnlessStopped = "unless-stopped" )
const ( // ServicePrefix is the prefix for references pointing to a service ServicePrefix = "service:" // ContainerPrefix is the prefix for references pointing to a container ContainerPrefix = "container:" // NetworkModeServicePrefix is the prefix for network_mode pointing to a service // Deprecated prefer ServicePrefix NetworkModeServicePrefix = ServicePrefix // NetworkModeContainerPrefix is the prefix for network_mode pointing to a container // Deprecated prefer ContainerPrefix NetworkModeContainerPrefix = ContainerPrefix )
const ( // VolumeTypeBind is the type for mounting host dir VolumeTypeBind = "bind" // VolumeTypeVolume is the type for remote storage volumes VolumeTypeVolume = "volume" // VolumeTypeTmpfs is the type for mounting tmpfs VolumeTypeTmpfs = "tmpfs" // VolumeTypeNamedPipe is the type for mounting Windows named pipes VolumeTypeNamedPipe = "npipe" // VolumeTypeCluster is the type for mounting container storage interface (CSI) volumes VolumeTypeCluster = "cluster" // VolumeTypeImage is the tpe for mounting an image VolumeTypeImage = "image" SElinuxShared = "z" SElinuxUnshared = "Z" )
const ( SELinuxShared string = "z" // SELinuxPrivate option indicates that the bind mount content is private and unshared SELinuxPrivate string = "Z" )
SELinux represents the SELinux re-labeling options.
const ( // PropagationRPrivate RPRIVATE PropagationRPrivate string = "rprivate" // PropagationPrivate PRIVATE PropagationPrivate string = "private" PropagationRShared string = "rshared" PropagationShared string = "shared" // PropagationRSlave RSLAVE PropagationRSlave string = "rslave" // PropagationSlave SLAVE PropagationSlave string = "slave" )
Propagation represents the propagation of a mount.
const ( // ServiceConditionCompletedSuccessfully is the type for waiting until a service has completed successfully (exit code 0). ServiceConditionCompletedSuccessfully = "service_completed_successfully" // ServiceConditionHealthy is the type for waiting until a service is healthy. ServiceConditionHealthy = "service_healthy" // ServiceConditionStarted is the type for waiting until a service has started (default). ServiceConditionStarted = "service_started" )
const (
	SecretConfigXValue = "x-#value"
)
    Variables ¶
This section is empty.
Functions ¶
func IgnoreDependencies ¶
func IgnoreDependencies(options *withServicesOptions)
func IncludeDependencies ¶
func IncludeDependencies(options *withServicesOptions)
func IncludeDependents ¶
func IncludeDependents(options *withServicesOptions)
func WithSecretContent ¶ added in v2.4.5
func WithSecretContent(o *marshallOptions)
Types ¶
type BlkioConfig ¶
type BlkioConfig struct {
	Weight          uint16           `yaml:"weight,omitempty" json:"weight,omitempty"`
	WeightDevice    []WeightDevice   `yaml:"weight_device,omitempty" json:"weight_device,omitempty"`
	DeviceReadBps   []ThrottleDevice `yaml:"device_read_bps,omitempty" json:"device_read_bps,omitempty"`
	DeviceReadIOps  []ThrottleDevice `yaml:"device_read_iops,omitempty" json:"device_read_iops,omitempty"`
	DeviceWriteBps  []ThrottleDevice `yaml:"device_write_bps,omitempty" json:"device_write_bps,omitempty"`
	DeviceWriteIOps []ThrottleDevice `yaml:"device_write_iops,omitempty" json:"device_write_iops,omitempty"`
	Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
}
    BlkioConfig define blkio config
type BuildConfig ¶
type BuildConfig struct {
	Context            string                    `yaml:"context,omitempty" json:"context,omitempty"`
	Dockerfile         string                    `yaml:"dockerfile,omitempty" json:"dockerfile,omitempty"`
	DockerfileInline   string                    `yaml:"dockerfile_inline,omitempty" json:"dockerfile_inline,omitempty"`
	Entitlements       []string                  `yaml:"entitlements,omitempty" json:"entitlements,omitempty"`
	Args               MappingWithEquals         `yaml:"args,omitempty" json:"args,omitempty"`
	Provenance         string                    `yaml:"provenance,omitempty" json:"provenance,omitempty"`
	SBOM               string                    `yaml:"sbom,omitempty" json:"sbom,omitempty"`
	SSH                SSHConfig                 `yaml:"ssh,omitempty" json:"ssh,omitempty"`
	Labels             Labels                    `yaml:"labels,omitempty" json:"labels,omitempty"`
	CacheFrom          StringList                `yaml:"cache_from,omitempty" json:"cache_from,omitempty"`
	CacheTo            StringList                `yaml:"cache_to,omitempty" json:"cache_to,omitempty"`
	NoCache            bool                      `yaml:"no_cache,omitempty" json:"no_cache,omitempty"`
	AdditionalContexts Mapping                   `yaml:"additional_contexts,omitempty" json:"additional_contexts,omitempty"`
	Pull               bool                      `yaml:"pull,omitempty" json:"pull,omitempty"`
	ExtraHosts         HostsList                 `yaml:"extra_hosts,omitempty" json:"extra_hosts,omitempty"`
	Isolation          string                    `yaml:"isolation,omitempty" json:"isolation,omitempty"`
	Network            string                    `yaml:"network,omitempty" json:"network,omitempty"`
	Target             string                    `yaml:"target,omitempty" json:"target,omitempty"`
	Secrets            []ServiceSecretConfig     `yaml:"secrets,omitempty" json:"secrets,omitempty"`
	ShmSize            UnitBytes                 `yaml:"shm_size,omitempty" json:"shm_size,omitempty"`
	Tags               StringList                `yaml:"tags,omitempty" json:"tags,omitempty"`
	Ulimits            map[string]*UlimitsConfig `yaml:"ulimits,omitempty" json:"ulimits,omitempty"`
	Platforms          StringList                `yaml:"platforms,omitempty" json:"platforms,omitempty"`
	Privileged         bool                      `yaml:"privileged,omitempty" json:"privileged,omitempty"`
	Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
}
    BuildConfig is a type for build
type Config ¶
type Config struct {
	Filename   string          `yaml:"-" json:"-"`
	Name       string          `yaml:"name,omitempty" json:"name,omitempty"`
	Services   Services        `yaml:"services" json:"services"`
	Networks   Networks        `yaml:"networks,omitempty" json:"networks,omitempty"`
	Volumes    Volumes         `yaml:"volumes,omitempty" json:"volumes,omitempty"`
	Secrets    Secrets         `yaml:"secrets,omitempty" json:"secrets,omitempty"`
	Configs    Configs         `yaml:"configs,omitempty" json:"configs,omitempty"`
	Extensions Extensions      `yaml:",inline" json:"-"`
	Include    []IncludeConfig `yaml:"include,omitempty" json:"include,omitempty"`
}
    Config is a full compose file configuration and model
func (Config) MarshalJSON ¶
MarshalJSON makes Config implement json.Marshaler
type ConfigDetails ¶
type ConfigDetails struct {
	Version     string
	WorkingDir  string
	ConfigFiles []ConfigFile
	Environment Mapping
}
    ConfigDetails are the details about a group of ConfigFiles
type ConfigFile ¶
type ConfigFile struct {
	// Filename is the name of the yaml configuration file
	Filename string
	// Content is the raw yaml content. Will be loaded from Filename if not set
	Content []byte
	// Config if the yaml tree for this config file. Will be parsed from Content if not set
	Config map[string]interface{}
}
    ConfigFile is a filename and the contents of the file as a Dict
func ToConfigFiles ¶
func ToConfigFiles(path []string) (f []ConfigFile)
func (ConfigFile) IsStdin ¶ added in v2.4.3
func (cf ConfigFile) IsStdin() bool
type ConfigObjConfig ¶
type ConfigObjConfig FileObjectConfig
ConfigObjConfig is the config for the swarm "Config" object
func (ConfigObjConfig) MarshalJSON ¶ added in v2.1.4
func (s ConfigObjConfig) MarshalJSON() ([]byte, error)
MarshalJSON makes ConfigObjConfig implement json.Marshaller
func (ConfigObjConfig) MarshalYAML ¶ added in v2.1.4
func (s ConfigObjConfig) MarshalYAML() (interface{}, error)
MarshalYAML makes ConfigObjConfig implement yaml.Marshaller
type CredentialSpecConfig ¶
type CredentialSpecConfig struct {
	Config     string     `yaml:"config,omitempty" json:"config,omitempty"` // Config was added in API v1.40
	File       string     `yaml:"file,omitempty" json:"file,omitempty"`
	Registry   string     `yaml:"registry,omitempty" json:"registry,omitempty"`
	Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
}
    CredentialSpecConfig for credential spec on Windows
type DependencyOption ¶
type DependencyOption func(options *withServicesOptions)
type DependsOnConfig ¶
type DependsOnConfig map[string]ServiceDependency
type DeployConfig ¶
type DeployConfig struct {
	Mode           string         `yaml:"mode,omitempty" json:"mode,omitempty"`
	Replicas       *int           `yaml:"replicas,omitempty" json:"replicas,omitempty"`
	Labels         Labels         `yaml:"labels,omitempty" json:"labels,omitempty"`
	UpdateConfig   *UpdateConfig  `yaml:"update_config,omitempty" json:"update_config,omitempty"`
	RollbackConfig *UpdateConfig  `yaml:"rollback_config,omitempty" json:"rollback_config,omitempty"`
	Resources      Resources      `yaml:"resources,omitempty" json:"resources,omitempty"`
	RestartPolicy  *RestartPolicy `yaml:"restart_policy,omitempty" json:"restart_policy,omitempty"`
	Placement      Placement      `yaml:"placement,omitempty" json:"placement,omitempty"`
	EndpointMode   string         `yaml:"endpoint_mode,omitempty" json:"endpoint_mode,omitempty"`
	Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
}
    DeployConfig the deployment configuration for a service
type DevelopConfig ¶
type DevelopConfig struct {
	Watch []Trigger `yaml:"watch,omitempty" json:"watch,omitempty"`
	Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
}
    type DeviceCount ¶
type DeviceCount int64
func (*DeviceCount) DecodeMapstructure ¶
func (c *DeviceCount) DecodeMapstructure(value interface{}) error
type DeviceMapping ¶ added in v2.2.0
type DeviceMapping struct {
	Source      string `yaml:"source,omitempty" json:"source,omitempty"`
	Target      string `yaml:"target,omitempty" json:"target,omitempty"`
	Permissions string `yaml:"permissions,omitempty" json:"permissions,omitempty"`
	Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
}
    type DeviceRequest ¶
type DeviceRequest struct {
	Capabilities []string    `yaml:"capabilities,omitempty" json:"capabilities,omitempty"`
	Driver       string      `yaml:"driver,omitempty" json:"driver,omitempty"`
	Count        DeviceCount `yaml:"count,omitempty" json:"count,omitempty"`
	IDs          []string    `yaml:"device_ids,omitempty" json:"device_ids,omitempty"`
	Options      Mapping     `yaml:"options,omitempty" json:"options,omitempty"`
}
    type DiscreteGenericResource ¶
type DiscreteGenericResource struct {
	Kind  string `json:"kind"`
	Value int64  `json:"value"`
	Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
}
    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 Duration ¶
Duration is a thin wrapper around time.Duration with improved JSON marshalling
func (*Duration) DecodeMapstructure ¶
func (Duration) MarshalJSON ¶
MarshalJSON makes Duration implement json.Marshaler
func (Duration) MarshalYAML ¶
MarshalYAML makes Duration implement yaml.Marshaler
func (*Duration) UnmarshalJSON ¶
type EnvFile ¶
type EnvFile struct {
	Path     string `yaml:"path,omitempty" json:"path,omitempty"`
	Required bool   `yaml:"required" json:"required"`
	Format   string `yaml:"format,omitempty" json:"format,omitempty"`
}
    func (*EnvFile) MarshalJSON ¶
MarshalJSON makes EnvFile implement json.Marshaler
func (EnvFile) MarshalYAML ¶
MarshalYAML makes EnvFile implement yaml.Marshaler
type ExtendsConfig ¶
type Extensions ¶
Extensions is a map of custom extension
func (Extensions) DeepCopy ¶ added in v2.1.3
func (e Extensions) DeepCopy(t Extensions)
type External ¶
type External bool
External identifies a Volume or Network as a reference to a resource that is not managed, and should already exist.
type FileMode ¶ added in v2.4.9
type FileMode int64
func (*FileMode) DecodeMapstructure ¶ added in v2.4.9
func (*FileMode) MarshalJSON ¶ added in v2.4.9
MarshalJSON makes FileMode implement json.Marshaller
func (*FileMode) MarshalYAML ¶ added in v2.4.9
MarshalYAML makes FileMode implement yaml.Marshaller
type FileObjectConfig ¶
type FileObjectConfig struct {
	Name        string `yaml:"name,omitempty" json:"name,omitempty"`
	File        string `yaml:"file,omitempty" json:"file,omitempty"`
	Environment string `yaml:"environment,omitempty" json:"environment,omitempty"`
	Content     string `yaml:"content,omitempty" json:"content,omitempty"`
	External       External          `yaml:"external,omitempty" json:"external,omitempty"`
	Labels         Labels            `yaml:"labels,omitempty" json:"labels,omitempty"`
	Driver         string            `yaml:"driver,omitempty" json:"driver,omitempty"`
	DriverOpts     map[string]string `yaml:"driver_opts,omitempty" json:"driver_opts,omitempty"`
	TemplateDriver string            `yaml:"template_driver,omitempty" json:"template_driver,omitempty"`
	Extensions     Extensions        `yaml:"#extensions,inline,omitempty" json:"-"`
	// contains filtered or unexported fields
}
    FileObjectConfig is a config type for a file used by a service
type FileReferenceConfig ¶
type FileReferenceConfig struct {
	Source string    `yaml:"source,omitempty" json:"source,omitempty"`
	Target string    `yaml:"target,omitempty" json:"target,omitempty"`
	UID    string    `yaml:"uid,omitempty" json:"uid,omitempty"`
	GID    string    `yaml:"gid,omitempty" json:"gid,omitempty"`
	Mode   *FileMode `yaml:"mode,omitempty" json:"mode,omitempty"`
	Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
}
    FileReferenceConfig for a reference to a swarm file object
type GenericResource ¶
type GenericResource struct {
	DiscreteResourceSpec *DiscreteGenericResource `yaml:"discrete_resource_spec,omitempty" json:"discrete_resource_spec,omitempty"`
	Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
}
    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:"test,omitempty" json:"test,omitempty"`
	Timeout       *Duration       `yaml:"timeout,omitempty" json:"timeout,omitempty"`
	Interval      *Duration       `yaml:"interval,omitempty" json:"interval,omitempty"`
	Retries       *uint64         `yaml:"retries,omitempty" json:"retries,omitempty"`
	StartPeriod   *Duration       `yaml:"start_period,omitempty" json:"start_period,omitempty"`
	StartInterval *Duration       `yaml:"start_interval,omitempty" json:"start_interval,omitempty"`
	Disable       bool            `yaml:"disable,omitempty" json:"disable,omitempty"`
	Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
}
    HealthCheckConfig the healthcheck configuration for a service
type HealthCheckTest ¶
type HealthCheckTest []string
HealthCheckTest is the command run to test the health of a service
func (*HealthCheckTest) DecodeMapstructure ¶
func (l *HealthCheckTest) DecodeMapstructure(value interface{}) error
type HostsList ¶
HostsList is a list of colon-separated host-ip mappings
func NewHostsList ¶
NewHostsList creates a HostsList from a list of `host=ip` strings
func (HostsList) AsList ¶
AsList returns host-ip mappings as a list of strings, using the given separator. The Docker Engine API expects ':' separators, the original format for '--add-hosts'. But an '=' separator is used in YAML/JSON renderings to make IPv6 addresses more readable (for example "my-host=::1" instead of "my-host:::1").
func (*HostsList) DecodeMapstructure ¶
func (HostsList) MarshalJSON ¶
func (HostsList) MarshalYAML ¶
type IPAMConfig ¶
type IPAMConfig struct {
	Driver     string      `yaml:"driver,omitempty" json:"driver,omitempty"`
	Config     []*IPAMPool `yaml:"config,omitempty" json:"config,omitempty"`
	Extensions Extensions  `yaml:"#extensions,inline,omitempty" json:"-"`
}
    IPAMConfig for a network
type IPAMPool ¶
type IPAMPool struct {
	Subnet             string     `yaml:"subnet,omitempty" json:"subnet,omitempty"`
	Gateway            string     `yaml:"gateway,omitempty" json:"gateway,omitempty"`
	IPRange            string     `yaml:"ip_range,omitempty" json:"ip_range,omitempty"`
	AuxiliaryAddresses Mapping    `yaml:"aux_addresses,omitempty" json:"aux_addresses,omitempty"`
	Extensions         Extensions `yaml:",inline" json:"-"`
}
    IPAMPool for a network
type IncludeConfig ¶
type IncludeConfig struct {
	Path             StringList `yaml:"path,omitempty" json:"path,omitempty"`
	ProjectDirectory string     `yaml:"project_directory,omitempty" json:"project_directory,omitempty"`
	EnvFile          StringList `yaml:"env_file,omitempty" json:"env_file,omitempty"`
}
    type Labels ¶
Labels is a mapping type for labels
func NewLabelsFromMappingWithEquals ¶ added in v2.4.6
func NewLabelsFromMappingWithEquals(mapping MappingWithEquals) Labels
func (*Labels) DecodeMapstructure ¶
func (Labels) ToMappingWithEquals ¶ added in v2.4.6
func (l Labels) ToMappingWithEquals() MappingWithEquals
type LoggingConfig ¶
type LoggingConfig struct {
	Driver  string  `yaml:"driver,omitempty" json:"driver,omitempty"`
	Options Options `yaml:"options,omitempty" json:"options,omitempty"`
	Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
}
    LoggingConfig the logging configuration for a service
type Mapping ¶
Mapping is a mapping type that can be converted from a list of key[=value] strings. For the key with an empty value (`key=`), or key without value (`key`), the mapped value is set to an empty string `""`.
func NewMapping ¶
NewMapping build a new Mapping from a set of KEY=VALUE strings
func (*Mapping) DecodeMapstructure ¶
func (Mapping) ToMappingWithEquals ¶
func (m Mapping) ToMappingWithEquals() MappingWithEquals
ToMappingWithEquals converts Mapping into a MappingWithEquals with pointer references
type MappingWithColon ¶
MappingWithColon is a mapping type that can be converted from a list of 'key: value' strings
type MappingWithEquals ¶
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.
func NewMappingWithEquals ¶
func NewMappingWithEquals(values []string) MappingWithEquals
NewMappingWithEquals build a new Mapping from a set of KEY=VALUE strings
func (*MappingWithEquals) DecodeMapstructure ¶
func (m *MappingWithEquals) DecodeMapstructure(value interface{}) error
func (MappingWithEquals) OverrideBy ¶
func (m MappingWithEquals) OverrideBy(other MappingWithEquals) MappingWithEquals
OverrideBy update MappingWithEquals with values from another MappingWithEquals
func (MappingWithEquals) RemoveEmpty ¶
func (m MappingWithEquals) RemoveEmpty() MappingWithEquals
RemoveEmpty excludes keys that are not associated with a value
func (MappingWithEquals) Resolve ¶
func (m MappingWithEquals) Resolve(lookupFn func(string) (string, bool)) MappingWithEquals
Resolve update a MappingWithEquals for keys without value (`key`, but not `key=`)
func (MappingWithEquals) ToMapping ¶ added in v2.4.6
func (m MappingWithEquals) ToMapping() Mapping
type ModelConfig ¶ added in v2.7.0
type ModelConfig struct {
	Name         string     `yaml:"name,omitempty" json:"name,omitempty"`
	Model        string     `yaml:"model,omitempty" json:"model,omitempty"`
	ContextSize  int        `yaml:"context_size,omitempty" json:"context_size,omitempty"`
	RuntimeFlags []string   `yaml:"runtime_flags,omitempty" json:"runtime_flags,omitempty"`
	Extensions   Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
}
    type Models ¶ added in v2.7.0
type Models map[string]ModelConfig
type MultiOptions ¶ added in v2.6.3
MultiOptions allow option to be repeated
func (*MultiOptions) DecodeMapstructure ¶ added in v2.6.3
func (d *MultiOptions) DecodeMapstructure(value interface{}) error
type NanoCPUs ¶ added in v2.0.1
type NanoCPUs float32
func (*NanoCPUs) DecodeMapstructure ¶ added in v2.0.1
type NetworkConfig ¶
type NetworkConfig struct {
	Name         string     `yaml:"name,omitempty" json:"name,omitempty"`
	Driver       string     `yaml:"driver,omitempty" json:"driver,omitempty"`
	DriverOpts   Options    `yaml:"driver_opts,omitempty" json:"driver_opts,omitempty"`
	Ipam         IPAMConfig `yaml:"ipam,omitempty" json:"ipam,omitempty"`
	External     External   `yaml:"external,omitempty" json:"external,omitempty"`
	Internal     bool       `yaml:"internal,omitempty" json:"internal,omitempty"`
	Attachable   bool       `yaml:"attachable,omitempty" json:"attachable,omitempty"`
	Labels       Labels     `yaml:"labels,omitempty" json:"labels,omitempty"`
	CustomLabels Labels     `yaml:"-" json:"-"`
	EnableIPv4   *bool      `yaml:"enable_ipv4,omitempty" json:"enable_ipv4,omitempty"`
	EnableIPv6   *bool      `yaml:"enable_ipv6,omitempty" json:"enable_ipv6,omitempty"`
	Extensions   Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
}
    NetworkConfig for a network
type Options ¶
Options is a mapping type for options we pass as-is to container runtime
func (*Options) DecodeMapstructure ¶
type Placement ¶
type Placement struct {
	Constraints []string               `yaml:"constraints,omitempty" json:"constraints,omitempty"`
	Preferences []PlacementPreferences `yaml:"preferences,omitempty" json:"preferences,omitempty"`
	MaxReplicas uint64                 `yaml:"max_replicas_per_node,omitempty" json:"max_replicas_per_node,omitempty"`
	Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
}
    Placement constraints for the service
type PlacementPreferences ¶
type PlacementPreferences struct {
	Spread string `yaml:"spread,omitempty" json:"spread,omitempty"`
	Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
}
    PlacementPreferences is the preferences for a service placement
type Project ¶
type Project struct {
	Name       string     `yaml:"name,omitempty" json:"name,omitempty"`
	WorkingDir string     `yaml:"-" json:"-"`
	Services   Services   `yaml:"services" json:"services"`
	Networks   Networks   `yaml:"networks,omitempty" json:"networks,omitempty"`
	Volumes    Volumes    `yaml:"volumes,omitempty" json:"volumes,omitempty"`
	Secrets    Secrets    `yaml:"secrets,omitempty" json:"secrets,omitempty"`
	Configs    Configs    `yaml:"configs,omitempty" json:"configs,omitempty"`
	Models     Models     `yaml:"models,omitempty" json:"models,omitempty"`
	Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"` // https://github.com/golang/go/issues/6213
	ComposeFiles []string `yaml:"-" json:"-"`
	Environment  Mapping  `yaml:"-" json:"-"`
	// DisabledServices track services which have been disable as profile is not active
	DisabledServices Services `yaml:"-" json:"-"`
	Profiles         []string `yaml:"-" json:"-"`
}
    Project is the result of loading a set of compose files Since v2, Project are managed as immutable objects. Each public functions which mutate Project state now return a copy of the original Project with the expected changes.
func (*Project) AllServices ¶
func (*Project) CheckContainerNameUnicity ¶ added in v2.1.0
CheckContainerNameUnicity validate project doesn't have services declaring the same container_name
func (*Project) ConfigNames ¶
ConfigNames return names for all configs in this Compose config
func (*Project) DisabledServiceNames ¶
DisabledServiceNames return names for all disabled services in this Compose config
func (*Project) ForEachService ¶
func (p *Project) ForEachService(names []string, fn ServiceFunc, options ...DependencyOption) error
ForEachService runs ServiceFunc on each service and dependencies according to DependencyPolicy
func (*Project) GetDependentsForService ¶
func (p *Project) GetDependentsForService(s ServiceConfig, filter ...func(ServiceDependency) bool) []string
func (Project) GetDisabledService ¶
func (p Project) GetDisabledService(name string) (ServiceConfig, error)
GetDisabledService retrieve disabled service by name
func (*Project) GetService ¶
func (p *Project) GetService(name string) (ServiceConfig, error)
GetService retrieve a specific service by name
func (*Project) GetServices ¶
GetServices retrieve services by names, or return all services if no name specified
func (*Project) MarshalJSON ¶
MarshalJSON marshal Project into a json document
func (*Project) MarshalYAML ¶
MarshalYAML marshal Project into a yaml tree
func (*Project) ModelNames ¶ added in v2.8.1
ModelNames return names for all models in this Compose config
func (*Project) NetworkNames ¶
NetworkNames return names for all volumes in this Compose config
func (*Project) RelativePath ¶
RelativePath resolve a relative path based project's working directory
func (*Project) SecretNames ¶
SecretNames return names for all secrets in this Compose config
func (*Project) ServiceNames ¶
ServiceNames return names for all services in this Compose config
func (*Project) ServicesWithBuild ¶
func (*Project) ServicesWithCapabilities ¶
func (*Project) ServicesWithDependsOn ¶
func (*Project) ServicesWithExtends ¶
func (*Project) ServicesWithModels ¶ added in v2.8.1
func (*Project) VolumeNames ¶
VolumeNames return names for all volumes in this Compose config
func (*Project) WithImagesResolved ¶
func (p *Project) WithImagesResolved(resolver func(named reference.Named) (godigest.Digest, error)) (*Project, error)
WithImagesResolved updates services images to include digest computed by a resolver function It returns a new Project instance with the changes and keep the original Project unchanged
func (*Project) WithProfiles ¶
WithProfiles disables services which don't match selected profiles It returns a new Project instance with the changes and keep the original Project unchanged
func (*Project) WithSelectedServices ¶
func (p *Project) WithSelectedServices(names []string, options ...DependencyOption) (*Project, error)
WithSelectedServices restricts the project model to selected services and dependencies It returns a new Project instance with the changes and keep the original Project unchanged
func (*Project) WithServicesDisabled ¶
WithServicesDisabled removes from the project model the given services and their references in all dependencies It returns a new Project instance with the changes and keep the original Project unchanged
func (*Project) WithServicesEnabled ¶
WithServicesEnabled ensures services are enabled and activate profiles accordingly It returns a new Project instance with the changes and keep the original Project unchanged
func (Project) WithServicesEnvironmentResolved ¶
WithServicesEnvironmentResolved parses env_files set for services to resolve the actual environment map for services It returns a new Project instance with the changes and keep the original Project unchanged
func (Project) WithServicesLabelsResolved ¶ added in v2.4.6
WithServicesLabelsResolved parses label_files set for services to resolve the actual label map for services It returns a new Project instance with the changes and keep the original Project unchanged
func (*Project) WithServicesTransform ¶
func (p *Project) WithServicesTransform(fn func(name string, s ServiceConfig) (ServiceConfig, error)) (*Project, error)
WithServicesTransform applies a transformation to project services and return a new project with transformation results
func (*Project) WithoutUnnecessaryResources ¶
WithoutUnnecessaryResources drops networks/volumes/secrets/configs that are not referenced by active services It returns a new Project instance with the changes and keep the original Project unchanged
type Resource ¶
type Resource struct {
	// TODO: types to convert from units and ratios
	NanoCPUs         NanoCPUs          `yaml:"cpus,omitempty" json:"cpus,omitempty"`
	MemoryBytes      UnitBytes         `yaml:"memory,omitempty" json:"memory,omitempty"`
	Pids             int64             `yaml:"pids,omitempty" json:"pids,omitempty"`
	Devices          []DeviceRequest   `yaml:"devices,omitempty" json:"devices,omitempty"`
	GenericResources []GenericResource `yaml:"generic_resources,omitempty" json:"generic_resources,omitempty"`
	Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
}
    Resource is a resource to be limited or reserved
type Resources ¶
type Resources struct {
	Limits       *Resource `yaml:"limits,omitempty" json:"limits,omitempty"`
	Reservations *Resource `yaml:"reservations,omitempty" json:"reservations,omitempty"`
	Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
}
    Resources the resource limits and reservations
type RestartPolicy ¶
type RestartPolicy struct {
	Condition   string    `yaml:"condition,omitempty" json:"condition,omitempty"`
	Delay       *Duration `yaml:"delay,omitempty" json:"delay,omitempty"`
	MaxAttempts *uint64   `yaml:"max_attempts,omitempty" json:"max_attempts,omitempty"`
	Window      *Duration `yaml:"window,omitempty" json:"window,omitempty"`
	Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
}
    RestartPolicy the service restart policy
type SSHConfig ¶
type SSHConfig []SSHKey
SSHConfig is a mapping type for SSH build config
func (*SSHConfig) DecodeMapstructure ¶
type SSHKey ¶
type SSHKey struct {
	ID   string `yaml:"id,omitempty" json:"id,omitempty"`
	Path string `path:"path,omitempty" json:"path,omitempty"`
}
    func (SSHKey) MarshalJSON ¶
MarshalJSON makes SSHKey implement json.Marshaller
func (SSHKey) MarshalYAML ¶
MarshalYAML makes SSHKey implement yaml.Marshaller
type SecretConfig ¶
type SecretConfig FileObjectConfig
SecretConfig for a secret
func (SecretConfig) MarshalJSON ¶ added in v2.1.4
func (s SecretConfig) MarshalJSON() ([]byte, error)
MarshalJSON makes SecretConfig implement json.Marshaller
func (SecretConfig) MarshalYAML ¶ added in v2.1.4
func (s SecretConfig) MarshalYAML() (interface{}, error)
MarshalYAML makes SecretConfig implement yaml.Marshaller
type ServiceConfig ¶
type ServiceConfig struct {
	Name     string   `yaml:"name,omitempty" json:"-"`
	Profiles []string `yaml:"profiles,omitempty" json:"profiles,omitempty"`
	Annotations  Mapping        `yaml:"annotations,omitempty" json:"annotations,omitempty"`
	Attach       *bool          `yaml:"attach,omitempty" json:"attach,omitempty"`
	Build        *BuildConfig   `yaml:"build,omitempty" json:"build,omitempty"`
	Develop      *DevelopConfig `yaml:"develop,omitempty" json:"develop,omitempty"`
	BlkioConfig  *BlkioConfig   `yaml:"blkio_config,omitempty" json:"blkio_config,omitempty"`
	CapAdd       []string       `yaml:"cap_add,omitempty" json:"cap_add,omitempty"`
	CapDrop      []string       `yaml:"cap_drop,omitempty" json:"cap_drop,omitempty"`
	CgroupParent string         `yaml:"cgroup_parent,omitempty" json:"cgroup_parent,omitempty"`
	Cgroup       string         `yaml:"cgroup,omitempty" json:"cgroup,omitempty"`
	CPUCount     int64          `yaml:"cpu_count,omitempty" json:"cpu_count,omitempty"`
	CPUPercent   float32        `yaml:"cpu_percent,omitempty" json:"cpu_percent,omitempty"`
	CPUPeriod    int64          `yaml:"cpu_period,omitempty" json:"cpu_period,omitempty"`
	CPUQuota     int64          `yaml:"cpu_quota,omitempty" json:"cpu_quota,omitempty"`
	CPURTPeriod  int64          `yaml:"cpu_rt_period,omitempty" json:"cpu_rt_period,omitempty"`
	CPURTRuntime int64          `yaml:"cpu_rt_runtime,omitempty" json:"cpu_rt_runtime,omitempty"`
	CPUS         float32        `yaml:"cpus,omitempty" json:"cpus,omitempty"`
	CPUSet       string         `yaml:"cpuset,omitempty" json:"cpuset,omitempty"`
	// Command for the service containers.
	// If set, overrides COMMAND from the image.
	//
	// Set to `[]` or an empty string to clear the command from the image.
	Command ShellCommand `yaml:"command,omitempty" json:"command"` // NOTE: we can NOT omitempty for JSON! see ShellCommand type for details.
	Configs           []ServiceConfigObjConfig `yaml:"configs,omitempty" json:"configs,omitempty"`
	ContainerName     string                   `yaml:"container_name,omitempty" json:"container_name,omitempty"`
	CredentialSpec    *CredentialSpecConfig    `yaml:"credential_spec,omitempty" json:"credential_spec,omitempty"`
	DependsOn         DependsOnConfig          `yaml:"depends_on,omitempty" json:"depends_on,omitempty"`
	Deploy            *DeployConfig            `yaml:"deploy,omitempty" json:"deploy,omitempty"`
	DeviceCgroupRules []string                 `yaml:"device_cgroup_rules,omitempty" json:"device_cgroup_rules,omitempty"`
	Devices           []DeviceMapping          `yaml:"devices,omitempty" json:"devices,omitempty"`
	DNS               StringList               `yaml:"dns,omitempty" json:"dns,omitempty"`
	DNSOpts           []string                 `yaml:"dns_opt,omitempty" json:"dns_opt,omitempty"`
	DNSSearch         StringList               `yaml:"dns_search,omitempty" json:"dns_search,omitempty"`
	Dockerfile        string                   `yaml:"dockerfile,omitempty" json:"dockerfile,omitempty"`
	DomainName        string                   `yaml:"domainname,omitempty" json:"domainname,omitempty"`
	// Entrypoint for the service containers.
	// If set, overrides 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.
	Provider        *ServiceProviderConfig           `yaml:"provider,omitempty" json:"provider,omitempty"`
	Environment     MappingWithEquals                `yaml:"environment,omitempty" json:"environment,omitempty"`
	EnvFiles        []EnvFile                        `yaml:"env_file,omitempty" json:"env_file,omitempty"`
	Expose          StringOrNumberList               `yaml:"expose,omitempty" json:"expose,omitempty"`
	Extends         *ExtendsConfig                   `yaml:"extends,omitempty" json:"extends,omitempty"`
	ExternalLinks   []string                         `yaml:"external_links,omitempty" json:"external_links,omitempty"`
	ExtraHosts      HostsList                        `yaml:"extra_hosts,omitempty" json:"extra_hosts,omitempty"`
	GroupAdd        []string                         `yaml:"group_add,omitempty" json:"group_add,omitempty"`
	Gpus            []DeviceRequest                  `yaml:"gpus,omitempty" json:"gpus,omitempty"`
	Hostname        string                           `yaml:"hostname,omitempty" json:"hostname,omitempty"`
	HealthCheck     *HealthCheckConfig               `yaml:"healthcheck,omitempty" json:"healthcheck,omitempty"`
	Image           string                           `yaml:"image,omitempty" json:"image,omitempty"`
	Init            *bool                            `yaml:"init,omitempty" json:"init,omitempty"`
	Ipc             string                           `yaml:"ipc,omitempty" json:"ipc,omitempty"`
	Isolation       string                           `yaml:"isolation,omitempty" json:"isolation,omitempty"`
	Labels          Labels                           `yaml:"labels,omitempty" json:"labels,omitempty"`
	LabelFiles      []string                         `yaml:"label_file,omitempty" json:"label_file,omitempty"`
	CustomLabels    Labels                           `yaml:"-" json:"-"`
	Links           []string                         `yaml:"links,omitempty" json:"links,omitempty"`
	Logging         *LoggingConfig                   `yaml:"logging,omitempty" json:"logging,omitempty"`
	LogDriver       string                           `yaml:"log_driver,omitempty" json:"log_driver,omitempty"`
	LogOpt          map[string]string                `yaml:"log_opt,omitempty" json:"log_opt,omitempty"`
	MemLimit        UnitBytes                        `yaml:"mem_limit,omitempty" json:"mem_limit,omitempty"`
	MemReservation  UnitBytes                        `yaml:"mem_reservation,omitempty" json:"mem_reservation,omitempty"`
	MemSwapLimit    UnitBytes                        `yaml:"memswap_limit,omitempty" json:"memswap_limit,omitempty"`
	MemSwappiness   UnitBytes                        `yaml:"mem_swappiness,omitempty" json:"mem_swappiness,omitempty"`
	MacAddress      string                           `yaml:"mac_address,omitempty" json:"mac_address,omitempty"`
	Models          map[string]*ServiceModelConfig   `yaml:"models,omitempty" json:"models,omitempty"`
	Net             string                           `yaml:"net,omitempty" json:"net,omitempty"`
	NetworkMode     string                           `yaml:"network_mode,omitempty" json:"network_mode,omitempty"`
	Networks        map[string]*ServiceNetworkConfig `yaml:"networks,omitempty" json:"networks,omitempty"`
	OomKillDisable  bool                             `yaml:"oom_kill_disable,omitempty" json:"oom_kill_disable,omitempty"`
	OomScoreAdj     int64                            `yaml:"oom_score_adj,omitempty" json:"oom_score_adj,omitempty"`
	Pid             string                           `yaml:"pid,omitempty" json:"pid,omitempty"`
	PidsLimit       int64                            `yaml:"pids_limit,omitempty" json:"pids_limit,omitempty"`
	Platform        string                           `yaml:"platform,omitempty" json:"platform,omitempty"`
	Ports           []ServicePortConfig              `yaml:"ports,omitempty" json:"ports,omitempty"`
	Privileged      bool                             `yaml:"privileged,omitempty" json:"privileged,omitempty"`
	PullPolicy      string                           `yaml:"pull_policy,omitempty" json:"pull_policy,omitempty"`
	ReadOnly        bool                             `yaml:"read_only,omitempty" json:"read_only,omitempty"`
	Restart         string                           `yaml:"restart,omitempty" json:"restart,omitempty"`
	Runtime         string                           `yaml:"runtime,omitempty" json:"runtime,omitempty"`
	Scale           *int                             `yaml:"scale,omitempty" json:"scale,omitempty"`
	Secrets         []ServiceSecretConfig            `yaml:"secrets,omitempty" json:"secrets,omitempty"`
	SecurityOpt     []string                         `yaml:"security_opt,omitempty" json:"security_opt,omitempty"`
	ShmSize         UnitBytes                        `yaml:"shm_size,omitempty" json:"shm_size,omitempty"`
	StdinOpen       bool                             `yaml:"stdin_open,omitempty" json:"stdin_open,omitempty"`
	StopGracePeriod *Duration                        `yaml:"stop_grace_period,omitempty" json:"stop_grace_period,omitempty"`
	StopSignal      string                           `yaml:"stop_signal,omitempty" json:"stop_signal,omitempty"`
	StorageOpt      map[string]string                `yaml:"storage_opt,omitempty" json:"storage_opt,omitempty"`
	Sysctls         Mapping                          `yaml:"sysctls,omitempty" json:"sysctls,omitempty"`
	Tmpfs           StringList                       `yaml:"tmpfs,omitempty" json:"tmpfs,omitempty"`
	Tty             bool                             `yaml:"tty,omitempty" json:"tty,omitempty"`
	Ulimits         map[string]*UlimitsConfig        `yaml:"ulimits,omitempty" json:"ulimits,omitempty"`
	UseAPISocket    bool                             `yaml:"use_api_socket,omitempty" json:"use_api_socket,omitempty"`
	User            string                           `yaml:"user,omitempty" json:"user,omitempty"`
	UserNSMode      string                           `yaml:"userns_mode,omitempty" json:"userns_mode,omitempty"`
	Uts             string                           `yaml:"uts,omitempty" json:"uts,omitempty"`
	VolumeDriver    string                           `yaml:"volume_driver,omitempty" json:"volume_driver,omitempty"`
	Volumes         []ServiceVolumeConfig            `yaml:"volumes,omitempty" json:"volumes,omitempty"`
	VolumesFrom     []string                         `yaml:"volumes_from,omitempty" json:"volumes_from,omitempty"`
	WorkingDir      string                           `yaml:"working_dir,omitempty" json:"working_dir,omitempty"`
	PostStart       []ServiceHook                    `yaml:"post_start,omitempty" json:"post_start,omitempty"`
	PreStop         []ServiceHook                    `yaml:"pre_stop,omitempty" json:"pre_stop,omitempty"`
	Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
}
    ServiceConfig is the configuration of one service
func (ServiceConfig) GetDependencies ¶
func (s ServiceConfig) GetDependencies() []string
GetDependencies retrieves all services this service depends on
func (ServiceConfig) GetDependents ¶
func (s ServiceConfig) GetDependents(p *Project) []string
GetDependents retrieves all services which depend on this service
func (ServiceConfig) GetPullPolicy ¶ added in v2.4.9
func (s ServiceConfig) GetPullPolicy() (string, time.Duration, error)
func (*ServiceConfig) GetScale ¶
func (s *ServiceConfig) GetScale() int
func (ServiceConfig) HasProfile ¶
func (s ServiceConfig) HasProfile(profiles []string) bool
HasProfile return true if service has no profile declared or has at least one profile matching
func (ServiceConfig) MarshalYAML ¶
func (s ServiceConfig) MarshalYAML() (interface{}, error)
MarshalYAML makes ServiceConfig implement yaml.Marshaller
func (*ServiceConfig) NetworksByPriority ¶
func (s *ServiceConfig) NetworksByPriority() []string
NetworksByPriority return the service networks IDs sorted according to Priority
func (*ServiceConfig) SetScale ¶
func (s *ServiceConfig) SetScale(scale int)
type ServiceConfigObjConfig ¶
type ServiceConfigObjConfig FileReferenceConfig
ServiceConfigObjConfig is the config obj configuration for a service
type ServiceDependency ¶
type ServiceDependency struct {
	Condition  string     `yaml:"condition,omitempty" json:"condition,omitempty"`
	Restart    bool       `yaml:"restart,omitempty" json:"restart,omitempty"`
	Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
	Required   bool       `yaml:"required" json:"required"`
}
    type ServiceFunc ¶
type ServiceFunc func(name string, service *ServiceConfig) error
type ServiceHook ¶ added in v2.3.0
type ServiceHook struct {
	Command     ShellCommand      `yaml:"command,omitempty" json:"command"`
	User        string            `yaml:"user,omitempty" json:"user,omitempty"`
	Privileged  bool              `yaml:"privileged,omitempty" json:"privileged,omitempty"`
	WorkingDir  string            `yaml:"working_dir,omitempty" json:"working_dir,omitempty"`
	Environment MappingWithEquals `yaml:"environment,omitempty" json:"environment,omitempty"`
	Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
}
    ServiceHook is a command to exec inside container by some lifecycle events
type ServiceModelConfig ¶ added in v2.7.0
type ServiceModelConfig struct {
	EndpointVariable string     `yaml:"endpoint_var,omitempty" json:"endpoint_var,omitempty"`
	ModelVariable    string     `yaml:"model_var,omitempty" json:"model_var,omitempty"`
	Extensions       Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
}
    type ServiceNetworkConfig ¶
type ServiceNetworkConfig struct {
	Aliases         []string `yaml:"aliases,omitempty" json:"aliases,omitempty"`
	DriverOpts      Options  `yaml:"driver_opts,omitempty" json:"driver_opts,omitempty"`
	GatewayPriority int      `yaml:"gw_priority,omitempty" json:"gw_priority,omitempty"`
	InterfaceName   string   `yaml:"interface_name,omitempty" json:"interface_name,omitempty"`
	Ipv4Address     string   `yaml:"ipv4_address,omitempty" json:"ipv4_address,omitempty"`
	Ipv6Address     string   `yaml:"ipv6_address,omitempty" json:"ipv6_address,omitempty"`
	LinkLocalIPs    []string `yaml:"link_local_ips,omitempty" json:"link_local_ips,omitempty"`
	MacAddress      string   `yaml:"mac_address,omitempty" json:"mac_address,omitempty"`
	Priority        int      `yaml:"priority,omitempty" json:"priority,omitempty"`
	Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
}
    ServiceNetworkConfig is the network configuration for a service
type ServicePortConfig ¶
type ServicePortConfig struct {
	Name        string `yaml:"name,omitempty" json:"name,omitempty"`
	Mode        string `yaml:"mode,omitempty" json:"mode,omitempty"`
	HostIP      string `yaml:"host_ip,omitempty" json:"host_ip,omitempty"`
	Target      uint32 `yaml:"target,omitempty" json:"target,omitempty"`
	Published   string `yaml:"published,omitempty" json:"published,omitempty"`
	Protocol    string `yaml:"protocol,omitempty" json:"protocol,omitempty"`
	AppProtocol string `yaml:"app_protocol,omitempty" json:"app_protocol,omitempty"`
	Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
}
    ServicePortConfig is the port configuration for a service
func ParsePortConfig ¶
func ParsePortConfig(value string) ([]ServicePortConfig, error)
ParsePortConfig parse short syntax for service port configuration
type ServiceProviderConfig ¶ added in v2.5.0
type ServiceProviderConfig struct {
	Type       string       `yaml:"type,omitempty" json:"type,omitempty"`
	Options    MultiOptions `yaml:"options,omitempty" json:"options,omitempty"`
	Extensions Extensions   `yaml:"#extensions,inline,omitempty" json:"-"`
}
    type ServiceSecretConfig ¶
type ServiceSecretConfig FileReferenceConfig
ServiceSecretConfig is the secret configuration for a service
type ServiceVolumeBind ¶
type ServiceVolumeBind struct {
	SELinux        string `yaml:"selinux,omitempty" json:"selinux,omitempty"`
	Propagation    string `yaml:"propagation,omitempty" json:"propagation,omitempty"`
	CreateHostPath bool   `yaml:"create_host_path,omitempty" json:"create_host_path,omitempty"`
	Recursive      string `yaml:"recursive,omitempty" json:"recursive,omitempty"`
	Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
}
    ServiceVolumeBind are options for a service volume of type bind
type ServiceVolumeConfig ¶
type ServiceVolumeConfig struct {
	Type        string               `yaml:"type,omitempty" json:"type,omitempty"`
	Source      string               `yaml:"source,omitempty" json:"source,omitempty"`
	Target      string               `yaml:"target,omitempty" json:"target,omitempty"`
	ReadOnly    bool                 `yaml:"read_only,omitempty" json:"read_only,omitempty"`
	Consistency string               `yaml:"consistency,omitempty" json:"consistency,omitempty"`
	Bind        *ServiceVolumeBind   `yaml:"bind,omitempty" json:"bind,omitempty"`
	Volume      *ServiceVolumeVolume `yaml:"volume,omitempty" json:"volume,omitempty"`
	Tmpfs       *ServiceVolumeTmpfs  `yaml:"tmpfs,omitempty" json:"tmpfs,omitempty"`
	Image       *ServiceVolumeImage  `yaml:"image,omitempty" json:"image,omitempty"`
	Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
}
    ServiceVolumeConfig are references to a volume used by a service
func (ServiceVolumeConfig) String ¶
func (s ServiceVolumeConfig) String() string
String render ServiceVolumeConfig as a volume string, one can parse back using loader.ParseVolume
type ServiceVolumeImage ¶ added in v2.6.0
type ServiceVolumeImage struct {
	SubPath    string     `yaml:"subpath,omitempty" json:"subpath,omitempty"`
	Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
}
    type ServiceVolumeTmpfs ¶
type ServiceVolumeTmpfs struct {
	Size UnitBytes `yaml:"size,omitempty" json:"size,omitempty"`
	Mode uint32 `yaml:"mode,omitempty" json:"mode,omitempty"`
	Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
}
    ServiceVolumeTmpfs are options for a service volume of type tmpfs
type ServiceVolumeVolume ¶
type ServiceVolumeVolume struct {
	Labels  Mapping `yaml:"labels,omitempty" json:"labels,omitempty"`
	NoCopy  bool    `yaml:"nocopy,omitempty" json:"nocopy,omitempty"`
	Subpath string  `yaml:"subpath,omitempty" json:"subpath,omitempty"`
	Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
}
    ServiceVolumeVolume are options for a service volume of type volume
type Services ¶
type Services map[string]ServiceConfig
Services is a map of ServiceConfig
func (Services) GetProfiles ¶
GetProfiles retrieve the profiles implicitly enabled by explicitly targeting selected services
type ShellCommand ¶
type ShellCommand []string
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 empty string 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 empty string) 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 go.yaml.in/yaml/v3 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.
func (*ShellCommand) DecodeMapstructure ¶
func (s *ShellCommand) DecodeMapstructure(value interface{}) error
func (ShellCommand) IsZero ¶
func (s ShellCommand) IsZero() bool
IsZero returns true if the slice is nil.
Empty (but non-nil) slices are NOT considered zero values.
func (ShellCommand) MarshalYAML ¶
func (s ShellCommand) MarshalYAML() (interface{}, error)
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 go.yaml.in/yaml/v3 by default serializes nil slices to `[]`.
type StringList ¶
type StringList []string
StringList is a type for fields that can be a string or list of strings
func (*StringList) DecodeMapstructure ¶
func (l *StringList) DecodeMapstructure(value interface{}) error
type StringOrNumberList ¶
type StringOrNumberList []string
StringOrNumberList is a type for fields that can be a list of strings or numbers
func (*StringOrNumberList) DecodeMapstructure ¶
func (l *StringOrNumberList) DecodeMapstructure(value interface{}) error
type ThrottleDevice ¶
type ThrottleDevice struct {
	Path string
	Rate UnitBytes
	Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
}
    ThrottleDevice is a structure that holds device:rate_per_second pair
type Trigger ¶
type Trigger struct {
	Path        string      `yaml:"path" json:"path"`
	Action      WatchAction `yaml:"action" json:"action"`
	Target      string      `yaml:"target,omitempty" json:"target,omitempty"`
	Exec        ServiceHook `yaml:"exec,omitempty" json:"exec,omitempty"`
	Include     []string    `yaml:"include,omitempty" json:"include,omitempty"`
	Ignore      []string    `yaml:"ignore,omitempty" json:"ignore,omitempty"`
	InitialSync bool        `yaml:"initial_sync,omitempty" json:"initial_sync,omitempty"`
	Extensions  Extensions  `yaml:"#extensions,inline,omitempty" json:"-"`
}
    type UlimitsConfig ¶
type UlimitsConfig struct {
	Single int `yaml:"single,omitempty" json:"single,omitempty"`
	Soft   int `yaml:"soft,omitempty" json:"soft,omitempty"`
	Hard   int `yaml:"hard,omitempty" json:"hard,omitempty"`
	Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
}
    UlimitsConfig the ulimit configuration
func (*UlimitsConfig) DecodeMapstructure ¶
func (u *UlimitsConfig) DecodeMapstructure(value interface{}) error
func (*UlimitsConfig) MarshalJSON ¶
func (u *UlimitsConfig) MarshalJSON() ([]byte, error)
MarshalJSON makes UlimitsConfig implement json.Marshaller
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) DecodeMapstructure ¶
func (UnitBytes) MarshalJSON ¶
MarshalJSON makes UnitBytes implement json.Marshaler
func (UnitBytes) MarshalYAML ¶
MarshalYAML makes UnitBytes implement yaml.Marshaller
type UpdateConfig ¶
type UpdateConfig struct {
	Parallelism     *uint64  `yaml:"parallelism,omitempty" json:"parallelism,omitempty"`
	Delay           Duration `yaml:"delay,omitempty" json:"delay,omitempty"`
	FailureAction   string   `yaml:"failure_action,omitempty" json:"failure_action,omitempty"`
	Monitor         Duration `yaml:"monitor,omitempty" json:"monitor,omitempty"`
	MaxFailureRatio float32  `yaml:"max_failure_ratio,omitempty" json:"max_failure_ratio,omitempty"`
	Order           string   `yaml:"order,omitempty" json:"order,omitempty"`
	Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
}
    UpdateConfig the service update configuration
type VolumeConfig ¶
type VolumeConfig struct {
	Name         string     `yaml:"name,omitempty" json:"name,omitempty"`
	Driver       string     `yaml:"driver,omitempty" json:"driver,omitempty"`
	DriverOpts   Options    `yaml:"driver_opts,omitempty" json:"driver_opts,omitempty"`
	External     External   `yaml:"external,omitempty" json:"external,omitempty"`
	Labels       Labels     `yaml:"labels,omitempty" json:"labels,omitempty"`
	CustomLabels Labels     `yaml:"-" json:"-"`
	Extensions   Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
}
    VolumeConfig for a volume
type WatchAction ¶
type WatchAction string
const ( WatchActionSync WatchAction = "sync" WatchActionRebuild WatchAction = "rebuild" WatchActionRestart WatchAction = "restart" WatchActionSyncRestart WatchAction = "sync+restart" WatchActionSyncExec WatchAction = "sync+exec" )
type WeightDevice ¶
type WeightDevice struct {
	Path   string
	Weight uint16
	Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
}
    WeightDevice is a structure that holds device:weight pair