github.com/demonoid81/moby@v0.0.0-20200517203328-62dd8e17c460/api/types/container/hostconfig_unix.go (about) 1 // +build !windows 2 3 package container // import "github.com/demonoid81/moby/api/types/container" 4 5 // IsValid indicates if an isolation technology is valid 6 func (i Isolation) IsValid() bool { 7 return i.IsDefault() 8 } 9 10 // NetworkName returns the name of the network stack. 11 func (n NetworkMode) NetworkName() string { 12 if n.IsBridge() { 13 return "bridge" 14 } else if n.IsHost() { 15 return "host" 16 } else if n.IsContainer() { 17 return "container" 18 } else if n.IsNone() { 19 return "none" 20 } else if n.IsDefault() { 21 return "default" 22 } else if n.IsUserDefined() { 23 return n.UserDefined() 24 } 25 return "" 26 } 27 28 // IsBridge indicates whether container uses the bridge network stack 29 func (n NetworkMode) IsBridge() bool { 30 return n == "bridge" 31 } 32 33 // IsHost indicates whether container uses the host network stack. 34 func (n NetworkMode) IsHost() bool { 35 return n == "host" 36 } 37 38 // IsUserDefined indicates user-created network 39 func (n NetworkMode) IsUserDefined() bool { 40 return !n.IsDefault() && !n.IsBridge() && !n.IsHost() && !n.IsNone() && !n.IsContainer() 41 }