|
@@ -4,22 +4,6 @@ import (
|
|
"strings"
|
|
"strings"
|
|
)
|
|
)
|
|
|
|
|
|
-// IsDefault indicates whether container uses the default network stack.
|
|
|
|
-func (n NetworkMode) IsDefault() bool {
|
|
|
|
- return n == "default"
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// IsNone indicates whether container isn't using a network stack.
|
|
|
|
-func (n NetworkMode) IsNone() bool {
|
|
|
|
- return n == "none"
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// IsContainer indicates whether container uses a container network stack.
|
|
|
|
-// Returns false as windows doesn't support this mode
|
|
|
|
-func (n NetworkMode) IsContainer() bool {
|
|
|
|
- return false
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
// IsBridge indicates whether container uses the bridge network stack
|
|
// IsBridge indicates whether container uses the bridge network stack
|
|
// in windows it is given the name NAT
|
|
// in windows it is given the name NAT
|
|
func (n NetworkMode) IsBridge() bool {
|
|
func (n NetworkMode) IsBridge() bool {
|
|
@@ -32,20 +16,9 @@ func (n NetworkMode) IsHost() bool {
|
|
return false
|
|
return false
|
|
}
|
|
}
|
|
|
|
|
|
-// IsPrivate indicates whether container uses its private network stack.
|
|
|
|
-func (n NetworkMode) IsPrivate() bool {
|
|
|
|
- return !(n.IsHost() || n.IsContainer())
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// ConnectedContainer is the id of the container which network this container is connected to.
|
|
|
|
-// Returns blank string on windows
|
|
|
|
-func (n NetworkMode) ConnectedContainer() string {
|
|
|
|
- return ""
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
// IsUserDefined indicates user-created network
|
|
// IsUserDefined indicates user-created network
|
|
func (n NetworkMode) IsUserDefined() bool {
|
|
func (n NetworkMode) IsUserDefined() bool {
|
|
- return !n.IsDefault() && !n.IsNone() && !n.IsBridge()
|
|
|
|
|
|
+ return !n.IsDefault() && !n.IsNone() && !n.IsBridge() && !n.IsContainer()
|
|
}
|
|
}
|
|
|
|
|
|
// IsHyperV indicates the use of a Hyper-V partition for isolation
|
|
// IsHyperV indicates the use of a Hyper-V partition for isolation
|
|
@@ -71,17 +44,11 @@ func (n NetworkMode) NetworkName() string {
|
|
return "nat"
|
|
return "nat"
|
|
} else if n.IsNone() {
|
|
} else if n.IsNone() {
|
|
return "none"
|
|
return "none"
|
|
|
|
+ } else if n.IsContainer() {
|
|
|
|
+ return "container"
|
|
} else if n.IsUserDefined() {
|
|
} else if n.IsUserDefined() {
|
|
return n.UserDefined()
|
|
return n.UserDefined()
|
|
}
|
|
}
|
|
|
|
|
|
return ""
|
|
return ""
|
|
}
|
|
}
|
|
-
|
|
|
|
-//UserDefined indicates user-created network
|
|
|
|
-func (n NetworkMode) UserDefined() string {
|
|
|
|
- if n.IsUserDefined() {
|
|
|
|
- return string(n)
|
|
|
|
- }
|
|
|
|
- return ""
|
|
|
|
-}
|
|
|