2014-02-12 04:04:39 +00:00
|
|
|
package runconfig
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/dotcloud/docker/engine"
|
|
|
|
"github.com/dotcloud/docker/nat"
|
2014-03-13 16:03:09 +00:00
|
|
|
"github.com/dotcloud/docker/utils"
|
2014-02-12 04:04:39 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type HostConfig struct {
|
|
|
|
Binds []string
|
|
|
|
ContainerIDFile string
|
2014-03-13 16:03:09 +00:00
|
|
|
LxcConf []utils.KeyValuePair
|
2014-02-12 04:04:39 +00:00
|
|
|
Privileged bool
|
|
|
|
PortBindings nat.PortMap
|
|
|
|
Links []string
|
|
|
|
PublishAllPorts bool
|
2014-03-13 16:03:09 +00:00
|
|
|
DriverOptions map[string][]string
|
2014-02-12 04:04:39 +00: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)
|
2014-03-13 16:03:09 +00:00
|
|
|
job.GetenvJson("DriverOptions", &hostConfig.DriverOptions)
|
2014-02-12 04:04:39 +00:00
|
|
|
if Binds := job.GetenvList("Binds"); Binds != nil {
|
|
|
|
hostConfig.Binds = Binds
|
|
|
|
}
|
|
|
|
if Links := job.GetenvList("Links"); Links != nil {
|
|
|
|
hostConfig.Links = Links
|
|
|
|
}
|
|
|
|
|
|
|
|
return hostConfig
|
|
|
|
}
|