2015-05-06 00:19:57 -04:00
|
|
|
package netlabel
|
|
|
|
|
2015-10-06 14:53:39 -04:00
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
)
|
2015-06-10 17:24:19 -04:00
|
|
|
|
2015-05-06 00:19:57 -04:00
|
|
|
const (
|
2015-06-14 12:03:42 -04:00
|
|
|
// Prefix constant marks the reserved label space for libnetwork
|
|
|
|
Prefix = "com.docker.network"
|
|
|
|
|
|
|
|
// DriverPrefix constant marks the reserved label space for libnetwork drivers
|
|
|
|
DriverPrefix = Prefix + ".driver"
|
|
|
|
|
2015-10-06 20:28:47 -04:00
|
|
|
// DriverPrivatePrefix constant marks the reserved label space
|
|
|
|
// for internal libnetwork drivers
|
|
|
|
DriverPrivatePrefix = DriverPrefix + ".private"
|
|
|
|
|
2015-05-06 00:19:57 -04:00
|
|
|
// GenericData constant that helps to identify an option as a Generic constant
|
2015-06-14 12:03:42 -04:00
|
|
|
GenericData = Prefix + ".generic"
|
2015-05-06 00:19:57 -04:00
|
|
|
|
|
|
|
// PortMap constant represents Port Mapping
|
2015-06-14 12:03:42 -04:00
|
|
|
PortMap = Prefix + ".portmap"
|
2015-05-06 00:19:57 -04:00
|
|
|
|
|
|
|
// MacAddress constant represents Mac Address config of a Container
|
2015-06-14 12:03:42 -04:00
|
|
|
MacAddress = Prefix + ".endpoint.macaddress"
|
2015-05-06 00:19:57 -04:00
|
|
|
|
2015-10-06 14:53:39 -04:00
|
|
|
// ExposedPorts constant represents the container's Exposed Ports
|
2015-06-14 12:03:42 -04:00
|
|
|
ExposedPorts = Prefix + ".endpoint.exposedports"
|
2015-05-06 00:19:57 -04:00
|
|
|
|
2016-09-19 18:48:06 -04:00
|
|
|
// DNSServers A list of DNS servers associated with the endpoint
|
|
|
|
DNSServers = Prefix + ".endpoint.dnsservers"
|
|
|
|
|
2015-05-06 00:19:57 -04:00
|
|
|
//EnableIPv6 constant represents enabling IPV6 at network level
|
2015-06-14 12:03:42 -04:00
|
|
|
EnableIPv6 = Prefix + ".enable_ipv6"
|
2015-06-10 17:24:19 -04:00
|
|
|
|
2015-10-06 15:08:54 -04:00
|
|
|
// DriverMTU constant represents the MTU size for the network driver
|
|
|
|
DriverMTU = DriverPrefix + ".mtu"
|
|
|
|
|
2015-06-10 17:24:19 -04:00
|
|
|
// OverlayBindInterface constant represents overlay driver bind interface
|
|
|
|
OverlayBindInterface = DriverPrefix + ".overlay.bind_interface"
|
|
|
|
|
|
|
|
// OverlayNeighborIP constant represents overlay driver neighbor IP
|
|
|
|
OverlayNeighborIP = DriverPrefix + ".overlay.neighbor_ip"
|
2015-10-03 19:11:50 -04:00
|
|
|
|
2016-02-26 14:54:35 -05:00
|
|
|
// OverlayVxlanIDList constant represents a list of VXLAN Ids as csv
|
|
|
|
OverlayVxlanIDList = DriverPrefix + ".overlay.vxlanid_list"
|
|
|
|
|
2015-10-03 19:11:50 -04:00
|
|
|
// Gateway represents the gateway for the network
|
|
|
|
Gateway = Prefix + ".gateway"
|
2015-12-21 20:29:39 -05:00
|
|
|
|
|
|
|
// Internal constant represents that the network is internal which disables default gateway service
|
|
|
|
Internal = Prefix + ".internal"
|
2017-02-27 17:23:12 -05:00
|
|
|
|
|
|
|
// ContainerIfacePrefix can be used to override the interface prefix used inside the container
|
|
|
|
ContainerIfacePrefix = Prefix + ".container_iface_prefix"
|
2015-05-06 00:19:57 -04:00
|
|
|
)
|
2015-06-10 17:24:19 -04:00
|
|
|
|
2015-10-06 20:28:47 -04:00
|
|
|
var (
|
|
|
|
// GlobalKVProvider constant represents the KV provider backend
|
|
|
|
GlobalKVProvider = MakeKVProvider("global")
|
|
|
|
|
|
|
|
// GlobalKVProviderURL constant represents the KV provider URL
|
|
|
|
GlobalKVProviderURL = MakeKVProviderURL("global")
|
|
|
|
|
|
|
|
// GlobalKVProviderConfig constant represents the KV provider Config
|
|
|
|
GlobalKVProviderConfig = MakeKVProviderConfig("global")
|
|
|
|
|
2016-01-27 19:37:47 -05:00
|
|
|
// GlobalKVClient constants represents the global kv store client
|
|
|
|
GlobalKVClient = MakeKVClient("global")
|
|
|
|
|
2015-10-06 20:28:47 -04:00
|
|
|
// LocalKVProvider constant represents the KV provider backend
|
|
|
|
LocalKVProvider = MakeKVProvider("local")
|
|
|
|
|
|
|
|
// LocalKVProviderURL constant represents the KV provider URL
|
|
|
|
LocalKVProviderURL = MakeKVProviderURL("local")
|
|
|
|
|
|
|
|
// LocalKVProviderConfig constant represents the KV provider Config
|
|
|
|
LocalKVProviderConfig = MakeKVProviderConfig("local")
|
2016-01-27 19:37:47 -05:00
|
|
|
|
|
|
|
// LocalKVClient constants represents the local kv store client
|
|
|
|
LocalKVClient = MakeKVClient("local")
|
2015-10-06 20:28:47 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
// MakeKVProvider returns the kvprovider label for the scope
|
|
|
|
func MakeKVProvider(scope string) string {
|
|
|
|
return DriverPrivatePrefix + scope + "kv_provider"
|
|
|
|
}
|
|
|
|
|
|
|
|
// MakeKVProviderURL returns the kvprovider url label for the scope
|
|
|
|
func MakeKVProviderURL(scope string) string {
|
|
|
|
return DriverPrivatePrefix + scope + "kv_provider_url"
|
|
|
|
}
|
|
|
|
|
|
|
|
// MakeKVProviderConfig returns the kvprovider config label for the scope
|
|
|
|
func MakeKVProviderConfig(scope string) string {
|
|
|
|
return DriverPrivatePrefix + scope + "kv_provider_config"
|
|
|
|
}
|
|
|
|
|
2016-01-27 19:37:47 -05:00
|
|
|
// MakeKVClient returns the kv client label for the scope
|
|
|
|
func MakeKVClient(scope string) string {
|
|
|
|
return DriverPrivatePrefix + scope + "kv_client"
|
|
|
|
}
|
|
|
|
|
2015-06-10 17:24:19 -04:00
|
|
|
// Key extracts the key portion of the label
|
2015-10-06 15:08:54 -04:00
|
|
|
func Key(label string) (key string) {
|
|
|
|
if kv := strings.SplitN(label, "=", 2); len(kv) > 0 {
|
|
|
|
key = kv[0]
|
|
|
|
}
|
|
|
|
return
|
2015-06-10 17:24:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Value extracts the value portion of the label
|
2015-10-06 15:08:54 -04:00
|
|
|
func Value(label string) (value string) {
|
|
|
|
if kv := strings.SplitN(label, "=", 2); len(kv) > 1 {
|
|
|
|
value = kv[1]
|
|
|
|
}
|
|
|
|
return
|
2015-06-10 17:24:19 -04:00
|
|
|
}
|
2015-10-06 14:53:39 -04:00
|
|
|
|
|
|
|
// KeyValue decomposes the label in the (key,value) pair
|
2015-10-06 15:08:54 -04:00
|
|
|
func KeyValue(label string) (key string, value string) {
|
|
|
|
if kv := strings.SplitN(label, "=", 2); len(kv) > 0 {
|
|
|
|
key = kv[0]
|
|
|
|
if len(kv) > 1 {
|
|
|
|
value = kv[1]
|
|
|
|
}
|
2015-10-06 14:53:39 -04:00
|
|
|
}
|
2015-10-06 15:08:54 -04:00
|
|
|
return
|
2015-10-06 14:53:39 -04:00
|
|
|
}
|