c5e6a4b3 |
package runconfig
|
ee6c3580 |
import (
"fmt"
"strings" |
a429ad1e |
|
907407d0 |
"github.com/docker/engine-api/types/container" |
7ac4232e |
) |
15e35c44 |
|
5170a2c0 |
// DefaultDaemonNetworkMode returns the default network stack the daemon should
// use. |
7ac4232e |
func DefaultDaemonNetworkMode() container.NetworkMode { |
e8026d8a |
return container.NetworkMode("nat") |
f6ed5905 |
} |
ead62b59 |
// IsPreDefinedNetwork indicates if a network is predefined by the daemon
func IsPreDefinedNetwork(network string) bool { |
e8026d8a |
return !container.NetworkMode(network).IsUserDefined() |
ead62b59 |
} |
ee6c3580 |
// ValidateNetMode ensures that the various combinations of requested
// network settings are valid. |
7ac4232e |
func ValidateNetMode(c *container.Config, hc *container.HostConfig) error { |
ee6c3580 |
if hc == nil {
return nil
}
parts := strings.Split(string(hc.NetworkMode), ":") |
e8026d8a |
if len(parts) > 1 { |
ee6c3580 |
return fmt.Errorf("invalid --net: %s", hc.NetworkMode)
}
return nil
}
|
d4b07324 |
// ValidateIsolation performs platform specific validation of the
// isolation in the hostconfig structure. Windows supports 'default' (or |
a429ad1e |
// blank), 'process', or 'hyperv'. |
d4b07324 |
func ValidateIsolation(hc *container.HostConfig) error { |
ee6c3580 |
// We may not be passed a host config, such as in the case of docker commit
if hc == nil {
return nil
}
if !hc.Isolation.IsValid() { |
a429ad1e |
return fmt.Errorf("invalid --isolation: %q. Windows supports 'default', 'process', or 'hyperv'", hc.Isolation) |
ee6c3580 |
}
return nil
} |