2014-02-11 23:04:39 -05:00
|
|
|
package runconfig
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/dotcloud/docker/engine"
|
|
|
|
"github.com/dotcloud/docker/nat"
|
2014-03-13 12:03:09 -04:00
|
|
|
"github.com/dotcloud/docker/utils"
|
2014-02-11 23:04:39 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
type HostConfig struct {
|
|
|
|
Binds []string
|
|
|
|
ContainerIDFile string
|
2014-03-13 12:03:09 -04:00
|
|
|
LxcConf []utils.KeyValuePair
|
2014-02-11 23:04:39 -05:00
|
|
|
Privileged bool
|
|
|
|
PortBindings nat.PortMap
|
|
|
|
Links []string
|
|
|
|
PublishAllPorts bool
|
2014-04-07 22:12:22 -04:00
|
|
|
Dns []string
|
|
|
|
DnsSearch []string
|
2014-04-08 06:02:17 -04:00
|
|
|
VolumesFrom []string
|
2014-02-11 23:04:39 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func ContainerHostConfigFromJob(job *engine.Job) *HostConfig {
|
|
|
|
hostConfig := &HostConfig{
|
|
|
|
ContainerIDFile: job.Getenv("ContainerIDFile"),
|
|
|
|
Privileged: job.GetenvBool("Privileged"),
|
|
|
|
PublishAllPorts: job.GetenvBool("PublishAllPorts"),
|
|
|
|
}
|
|
|
|
job.GetenvJson("LxcConf", &hostConfig.LxcConf)
|
|
|
|
job.GetenvJson("PortBindings", &hostConfig.PortBindings)
|
|
|
|
if Binds := job.GetenvList("Binds"); Binds != nil {
|
|
|
|
hostConfig.Binds = Binds
|
|
|
|
}
|
|
|
|
if Links := job.GetenvList("Links"); Links != nil {
|
|
|
|
hostConfig.Links = Links
|
|
|
|
}
|
2014-04-07 22:12:22 -04:00
|
|
|
if Dns := job.GetenvList("Dns"); Dns != nil {
|
|
|
|
hostConfig.Dns = Dns
|
|
|
|
}
|
|
|
|
if DnsSearch := job.GetenvList("DnsSearch"); DnsSearch != nil {
|
|
|
|
hostConfig.DnsSearch = DnsSearch
|
|
|
|
}
|
2014-04-08 06:02:17 -04:00
|
|
|
if VolumesFrom := job.GetenvList("VolumesFrom"); VolumesFrom != nil {
|
|
|
|
hostConfig.VolumesFrom = VolumesFrom
|
|
|
|
}
|
2014-02-11 23:04:39 -05:00
|
|
|
return hostConfig
|
|
|
|
}
|