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
|
|
|
|
EnableCors bool
|
|
|
|
Dns []string
|
|
|
|
EnableIptables bool
|
|
|
|
BridgeIface string
|
|
|
|
DefaultIp net.IP
|
|
|
|
InterContainerCommunication bool
|
2013-11-15 02:02:09 -05:00
|
|
|
GraphDriver string
|
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")
|
|
|
|
config.EnableCors = job.GetenvBool("EnableCors")
|
|
|
|
if dns := job.Getenv("Dns"); dns != "" {
|
|
|
|
config.Dns = []string{dns}
|
|
|
|
}
|
|
|
|
config.EnableIptables = job.GetenvBool("EnableIptables")
|
|
|
|
if br := job.Getenv("BridgeIface"); br != "" {
|
|
|
|
config.BridgeIface = br
|
|
|
|
} else {
|
|
|
|
config.BridgeIface = DefaultNetworkBridge
|
|
|
|
}
|
|
|
|
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-10-21 12:04:42 -04:00
|
|
|
return &config
|
|
|
|
}
|