2013-10-04 22:25:15 -04:00
|
|
|
package docker
|
|
|
|
|
|
|
|
import (
|
2013-10-21 12:04:42 -04:00
|
|
|
"github.com/dotcloud/docker/engine"
|
2013-11-07 15:19:24 -05:00
|
|
|
"net"
|
2013-10-04 22:25:15 -04:00
|
|
|
)
|
|
|
|
|
2013-10-21 12:04:42 -04:00
|
|
|
// FIXME: separate runtime configuration from http api configuration
|
2013-10-04 22:25:15 -04:00
|
|
|
type DaemonConfig struct {
|
2013-10-10 16:48:22 -04:00
|
|
|
Pidfile string
|
2013-10-23 04:09:16 -04:00
|
|
|
Root string
|
2013-10-10 16:48:22 -04:00
|
|
|
AutoRestart bool
|
|
|
|
Dns []string
|
|
|
|
EnableIptables bool
|
2014-01-27 23:35:05 -05:00
|
|
|
EnableIpForward bool
|
2013-10-10 16:48:22 -04:00
|
|
|
BridgeIface string
|
2013-12-13 10:47:19 -05:00
|
|
|
BridgeIp string
|
2013-10-10 16:48:22 -04:00
|
|
|
DefaultIp net.IP
|
|
|
|
InterContainerCommunication bool
|
2013-11-15 02:02:09 -05:00
|
|
|
GraphDriver string
|
2013-12-19 18:16:54 -05:00
|
|
|
Mtu int
|
2013-10-04 22:25:15 -04:00
|
|
|
}
|
2013-10-21 12:04:42 -04:00
|
|
|
|
2013-10-23 04:00:31 -04:00
|
|
|
// ConfigFromJob creates and returns a new DaemonConfig object
|
2013-10-21 12:04:42 -04:00
|
|
|
// by parsing the contents of a job's environment.
|
2013-10-23 04:00:31 -04:00
|
|
|
func ConfigFromJob(job *engine.Job) *DaemonConfig {
|
2013-10-21 12:04:42 -04:00
|
|
|
var config DaemonConfig
|
|
|
|
config.Pidfile = job.Getenv("Pidfile")
|
2013-10-23 04:09:16 -04:00
|
|
|
config.Root = job.Getenv("Root")
|
2013-10-21 12:04:42 -04:00
|
|
|
config.AutoRestart = job.GetenvBool("AutoRestart")
|
2013-11-22 12:55:27 -05:00
|
|
|
if dns := job.GetenvList("Dns"); dns != nil {
|
|
|
|
config.Dns = dns
|
2013-10-21 12:04:42 -04:00
|
|
|
}
|
|
|
|
config.EnableIptables = job.GetenvBool("EnableIptables")
|
2014-01-27 23:35:05 -05:00
|
|
|
config.EnableIpForward = job.GetenvBool("EnableIpForward")
|
2013-10-21 12:04:42 -04:00
|
|
|
if br := job.Getenv("BridgeIface"); br != "" {
|
|
|
|
config.BridgeIface = br
|
|
|
|
} else {
|
|
|
|
config.BridgeIface = DefaultNetworkBridge
|
|
|
|
}
|
2013-12-13 10:47:19 -05:00
|
|
|
config.BridgeIp = job.Getenv("BridgeIp")
|
2013-10-21 12:04:42 -04:00
|
|
|
config.DefaultIp = net.ParseIP(job.Getenv("DefaultIp"))
|
|
|
|
config.InterContainerCommunication = job.GetenvBool("InterContainerCommunication")
|
2013-11-15 02:02:09 -05:00
|
|
|
config.GraphDriver = job.Getenv("GraphDriver")
|
2013-12-19 18:16:54 -05:00
|
|
|
if mtu := job.GetenvInt("Mtu"); mtu != -1 {
|
|
|
|
config.Mtu = mtu
|
|
|
|
} else {
|
|
|
|
config.Mtu = DefaultNetworkMtu
|
|
|
|
}
|
2013-10-21 12:04:42 -04:00
|
|
|
return &config
|
|
|
|
}
|