2014-10-15 09:24:20 +00:00
|
|
|
package script
|
|
|
|
|
|
|
|
const (
|
2015-01-11 18:35:30 +00:00
|
|
|
DefaultDockerNetworkMode = "bridge"
|
2014-10-15 09:24:20 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Docker stores the configuration details for
|
|
|
|
// configuring docker container.
|
|
|
|
type Docker struct {
|
2015-01-11 18:35:30 +00:00
|
|
|
// NetworkMode (also known as `--net` option)
|
|
|
|
// Could be set only if Docker is running in privileged mode
|
|
|
|
NetworkMode *string `yaml:"net,omitempty"`
|
2014-11-20 10:18:12 +00:00
|
|
|
|
2015-01-11 18:35:30 +00:00
|
|
|
// Hostname (also known as `--hostname` option)
|
|
|
|
// Could be set only if Docker is running in privileged mode
|
|
|
|
Hostname *string `yaml:"hostname,omitempty"`
|
2014-10-15 09:24:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// DockerNetworkMode returns DefaultNetworkMode
|
|
|
|
// when Docker.NetworkMode is empty.
|
|
|
|
// DockerNetworkMode returns Docker.NetworkMode
|
|
|
|
// when it is not empty.
|
|
|
|
func DockerNetworkMode(d *Docker) string {
|
2015-01-11 18:35:30 +00:00
|
|
|
if d == nil || d.NetworkMode == nil {
|
|
|
|
return DefaultDockerNetworkMode
|
|
|
|
}
|
|
|
|
return *d.NetworkMode
|
2014-10-15 09:24:20 +00:00
|
|
|
}
|
2014-11-20 10:18:12 +00:00
|
|
|
|
|
|
|
// DockerNetworkMode returns empty string
|
|
|
|
// when Docker.NetworkMode is empty.
|
|
|
|
// DockerNetworkMode returns Docker.NetworkMode
|
|
|
|
// when it is not empty.
|
|
|
|
func DockerHostname(d *Docker) string {
|
2015-01-11 18:35:30 +00:00
|
|
|
if d == nil || d.Hostname == nil {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
return *d.Hostname
|
2014-11-20 10:18:12 +00:00
|
|
|
}
|