2015-06-23 13:13:42 -04:00
|
|
|
package runconfig
|
|
|
|
|
2015-09-18 21:21:57 -04:00
|
|
|
import "strings"
|
|
|
|
|
2015-07-25 05:11:45 -04:00
|
|
|
// IsDefault indicates whether container uses the default network stack.
|
2015-06-23 13:13:42 -04:00
|
|
|
func (n NetworkMode) IsDefault() bool {
|
|
|
|
return n == "default"
|
|
|
|
}
|
|
|
|
|
2015-09-18 21:21:57 -04:00
|
|
|
// IsHyperV indicates the use of Hyper-V Containers for isolation (as opposed
|
|
|
|
// to Windows Server Containers
|
|
|
|
func (i IsolationLevel) IsHyperV() bool {
|
|
|
|
return strings.ToLower(string(i)) == "hyperv"
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsValid indicates is an isolation level is valid
|
|
|
|
func (i IsolationLevel) IsValid() bool {
|
|
|
|
return i.IsDefault() || i.IsHyperV()
|
|
|
|
}
|
|
|
|
|
2015-07-25 05:11:45 -04:00
|
|
|
// DefaultDaemonNetworkMode returns the default network stack the daemon should
|
|
|
|
// use.
|
2015-06-23 13:13:42 -04:00
|
|
|
func DefaultDaemonNetworkMode() NetworkMode {
|
|
|
|
return NetworkMode("default")
|
|
|
|
}
|
|
|
|
|
2015-07-25 05:11:45 -04:00
|
|
|
// NetworkName returns the name of the network stack.
|
2015-06-23 13:13:42 -04:00
|
|
|
func (n NetworkMode) NetworkName() string {
|
|
|
|
if n.IsDefault() {
|
|
|
|
return "default"
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
2015-07-09 18:12:36 -04:00
|
|
|
|
|
|
|
// MergeConfigs merges the specified container Config and HostConfig.
|
|
|
|
// It creates a ContainerConfigWrapper.
|
|
|
|
func MergeConfigs(config *Config, hostConfig *HostConfig) *ContainerConfigWrapper {
|
|
|
|
return &ContainerConfigWrapper{
|
|
|
|
config,
|
|
|
|
hostConfig,
|
|
|
|
}
|
|
|
|
}
|
2015-10-25 19:09:54 -04:00
|
|
|
|
|
|
|
// IsPreDefinedNetwork indicates if a network is predefined by the daemon
|
|
|
|
func IsPreDefinedNetwork(network string) bool {
|
|
|
|
return false
|
|
|
|
}
|