mirror of https://github.com/docker/docs.git
handle compat
Signed-off-by: Victor Vieux <victorvieux@gmail.com>
This commit is contained in:
parent
79b128172d
commit
e8e9d553a2
|
@ -24,6 +24,42 @@ func parseEnv(e string) (bool, string, string) {
|
||||||
return false, "", ""
|
return false, "", ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: Temporary fix to handle forward/backward compatibility between Docker <1.6 and >=1.7
|
||||||
|
// ContainerConfig should be handling converting to/from different docker versions
|
||||||
|
func consolidateResourceFields(c *dockerclient.ContainerConfig) {
|
||||||
|
if c.Memory != c.HostConfig.Memory {
|
||||||
|
if c.Memory != 0 {
|
||||||
|
c.HostConfig.Memory = c.Memory
|
||||||
|
} else {
|
||||||
|
c.Memory = c.HostConfig.Memory
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.MemorySwap != c.HostConfig.MemorySwap {
|
||||||
|
if c.Memory != 0 {
|
||||||
|
c.HostConfig.MemorySwap = c.MemorySwap
|
||||||
|
} else {
|
||||||
|
c.MemorySwap = c.HostConfig.MemorySwap
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.CpuShares != c.HostConfig.CpuShares {
|
||||||
|
if c.CpuShares != 0 {
|
||||||
|
c.HostConfig.CpuShares = c.CpuShares
|
||||||
|
} else {
|
||||||
|
c.CpuShares = c.HostConfig.CpuShares
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.Cpuset != c.HostConfig.CpusetCpus {
|
||||||
|
if c.Cpuset != "" {
|
||||||
|
c.HostConfig.CpusetCpus = c.Cpuset
|
||||||
|
} else {
|
||||||
|
c.Cpuset = c.HostConfig.CpusetCpus
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// BuildContainerConfig creates a cluster.ContainerConfig from a dockerclient.ContainerConfig
|
// BuildContainerConfig creates a cluster.ContainerConfig from a dockerclient.ContainerConfig
|
||||||
func BuildContainerConfig(c dockerclient.ContainerConfig) *ContainerConfig {
|
func BuildContainerConfig(c dockerclient.ContainerConfig) *ContainerConfig {
|
||||||
var (
|
var (
|
||||||
|
@ -75,6 +111,8 @@ func BuildContainerConfig(c dockerclient.ContainerConfig) *ContainerConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
consolidateResourceFields(&c)
|
||||||
|
|
||||||
return &ContainerConfig{c}
|
return &ContainerConfig{c}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue