Documentation ¶
Index ¶
- Constants
- func Interpolate(str string, valueGetter ValueGetter, v bool) (string, error)
- func InterpolateConfig(config genericMap, valueGetter ValueGetter, v *version.Version) error
- func IsASCIIDigit(b byte) bool
- func IsASCIILetter(b byte) bool
- type CanonicalDockerComposeConfig
- type Healthcheck
- type HealthcheckTest
- type PathMapping
- type PortBinding
- type Service
- type ServiceHealthiness
- type ServiceVolume
- type ValueGetter
- type XProperties
Constants ¶
const ( HealthcheckCommandShell = "CMD-SHELL" HealthcheckCommandCmd = "CMD" HealthcheckCommandNone = "NONE" HealthcheckDefaultInterval = 30 * time.Second HealthcheckDefaultTimeout = 30 * time.Second HealthcheckDefaultRetries = 3 )
Variables ¶
This section is empty.
Functions ¶
func Interpolate ¶
func Interpolate(str string, valueGetter ValueGetter, v bool) (string, error)
Interpolate substitutes docker-compose style variables in the str. The docker-compose 2.1+ syntax is used if and only if version is true. The implementation is not strict on the syntax between two paired curly braces, but is otherwise identical to the Python implementation: https://github.com/docker/compose/blob/master/compose/config/interpolation.py
func InterpolateConfig ¶
func InterpolateConfig(config genericMap, valueGetter ValueGetter, v *version.Version) error
InterpolateConfig takes the root of a docker compose file as a generic structure and substitutes variables in it. The implementation substitutes exactly the same sections as docker compose: https://github.com/docker/compose/master/compose/config/config.py. TODO https://github.com/kube-compose/kube-compose/issues/11 support arbitrary map types instead of genericMap.
func IsASCIIDigit ¶
IsASCIIDigit returns true if and only if b is the ASCII code for a digit.
func IsASCIILetter ¶
IsASCIILetter returns true if and only if b is the ASCII code for a letter.
Types ¶
type CanonicalDockerComposeConfig ¶
type CanonicalDockerComposeConfig struct { Services map[string]*Service // For each docker compose file that was merged together, the root level x- properties as a generic map. // Givens elements e_i and e_j of the slice, with indices i and j, respectively, such that i > j, XProperties e_i have a higher priority // than XProperties e_j. Intuitively, elements later in the list take precedence over those earlier in the list. // The user of this package can choose to implement merging of XProperties as appropriate. XProperties []XProperties }
CanonicalDockerComposeConfig is a canonical representation of docker compose configuration. It represents one ore more docker compose files that have been merged together using logic close to docker compose. Similarly, extends will have been processed as well (see https://docs.docker.com/compose/compose-file/compose-file-v2/#extends).
func New ¶
func New(files []string) (*CanonicalDockerComposeConfig, error)
New loads docker compose configuration from a slice of files. If files is an empty slice then the standard docker compose file locations (relative to the current working directory are considered).
type Healthcheck ¶
type Healthcheck struct { Interval time.Duration IsShell bool StartPeriod time.Duration Retries uint Test []string Timeout time.Duration }
func ParseHealthcheck ¶
func ParseHealthcheck(i *healthcheckInternal) (*Healthcheck, bool, error)
type HealthcheckTest ¶
type HealthcheckTest struct {
Values []string
}
type PathMapping ¶
type PathMapping struct { HasHostPath bool // false if and only if the docker engine should create a volume. HasMode bool // true if and only if the path mapping explicitly set the mode. HostPath string // If this starts with a . or ~ then those should be expanded as appropriate. Mode string ContainerPath string }
PathMapping is a representation of a short docker-compose volume. Instead of a string pointer we use a pair of boolean and string for host path and mode. This is because merging (and detection of duplicates) is to be implemented with struct equality. Defining the struct this way would align the merging behavior with docker compose.
type PortBinding ¶
type PortBinding struct { // the internal port; the port on which the container would listen. At least 0 and less than 65536. Internal int32 // the minimum external port. At least -1 and less than 65536. -1 if the internal port is not published. ExternalMin int32 // the maximum external port. This value is undefined if ExternalMin is -1. Otherwise, at least 0 and less than 65536. // Docker will choose from a random available port from the range to map to the internal port. ExternalMax int32 // one of "udp", "tcp" and "sctp" Protocol string // the host (see docker for more details). Can be an empty string if the host was not set in the specification. Host string }
PortBinding is the parsed/canonical form of a docker publish port specification.
type Service ¶
type Service struct { // When adding a field here, please update merge.go with the logic required to merge these fields. Command []string // TODO https://github.com/kube-compose/kube-compose/issues/214 consider simplifying to map[string]ServiceHealthiness DependsOn map[string]ServiceHealthiness Entrypoint []string Environment map[string]string Healthcheck *Healthcheck HealthcheckDisabled bool Image string Name string Ports []PortBinding Privileged bool Restart string User *string Volumes []ServiceVolume WorkingDir string }
Service is the final representation of a docker-compose service, after all docker compose files have been merged. Service is a smaller piece of CanonicalDockerComposeConfig.
type ServiceHealthiness ¶
type ServiceHealthiness int
https://github.com/docker/compose/blob/master/compose/config/config_schema_v2.1.json
const ( ServiceStarted ServiceHealthiness = 0 ServiceHealthy ServiceHealthiness = 1 )
type ServiceVolume ¶
type ServiceVolume struct {
Short *PathMapping
}
ServiceVolume is the type used to encode each volume of a docker compose service.
type ValueGetter ¶
type XProperties ¶
type XProperties map[string]interface{}
This type is used to represent extension fields, see https://docs.docker.com/compose/compose-file/#extension-fields.