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-03-13 12:03:09 -04:00
|
|
|
DriverOptions map[string][]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)
|
2014-03-13 12:03:09 -04:00
|
|
|
job.GetenvJson("DriverOptions", &hostConfig.DriverOptions)
|
2014-02-11 23:04:39 -05:00
|
|
|
if Binds := job.GetenvList("Binds"); Binds != nil {
|
|
|
|
hostConfig.Binds = Binds
|
|
|
|
}
|
|
|
|
if Links := job.GetenvList("Links"); Links != nil {
|
|
|
|
hostConfig.Links = Links
|
|
|
|
}
|
|
|
|
|
|
|
|
return hostConfig
|
|
|
|
}
|