2015-05-06 04:19:57 +00:00
|
|
|
package netlabel
|
|
|
|
|
2015-06-10 21:24:19 +00:00
|
|
|
import "strings"
|
|
|
|
|
2015-05-06 04:19:57 +00:00
|
|
|
const (
|
2015-06-14 16:03:42 +00: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-07 00:28:47 +00:00
|
|
|
// DriverPrivatePrefix constant marks the reserved label space
|
|
|
|
// for internal libnetwork drivers
|
|
|
|
DriverPrivatePrefix = DriverPrefix + ".private"
|
|
|
|
|
2015-05-06 04:19:57 +00:00
|
|
|
// GenericData constant that helps to identify an option as a Generic constant
|
2015-06-14 16:03:42 +00:00
|
|
|
GenericData = Prefix + ".generic"
|
2015-05-06 04:19:57 +00:00
|
|
|
|
|
|
|
// PortMap constant represents Port Mapping
|
2015-06-14 16:03:42 +00:00
|
|
|
PortMap = Prefix + ".portmap"
|
2015-05-06 04:19:57 +00:00
|
|
|
|
|
|
|
// MacAddress constant represents Mac Address config of a Container
|
2015-06-14 16:03:42 +00:00
|
|
|
MacAddress = Prefix + ".endpoint.macaddress"
|
2015-05-06 04:19:57 +00:00
|
|
|
|
|
|
|
// ExposedPorts constant represents exposedports of a Container
|
2015-06-14 16:03:42 +00:00
|
|
|
ExposedPorts = Prefix + ".endpoint.exposedports"
|
2015-05-06 04:19:57 +00:00
|
|
|
|
|
|
|
//EnableIPv6 constant represents enabling IPV6 at network level
|
2015-06-14 16:03:42 +00:00
|
|
|
EnableIPv6 = Prefix + ".enable_ipv6"
|
2015-06-10 21:24:19 +00: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 23:11:50 +00:00
|
|
|
|
|
|
|
// Gateway represents the gateway for the network
|
|
|
|
Gateway = Prefix + ".gateway"
|
2015-05-06 04:19:57 +00:00
|
|
|
)
|
2015-06-10 21:24:19 +00:00
|
|
|
|
2015-10-07 00:28:47 +00: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")
|
|
|
|
|
|
|
|
// 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")
|
|
|
|
)
|
|
|
|
|
|
|
|
// 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"
|
|
|
|
}
|
|
|
|
|
2015-06-10 21:24:19 +00:00
|
|
|
// Key extracts the key portion of the label
|
|
|
|
func Key(label string) string {
|
|
|
|
kv := strings.SplitN(label, "=", 2)
|
|
|
|
|
|
|
|
return kv[0]
|
|
|
|
}
|
|
|
|
|
|
|
|
// Value extracts the value portion of the label
|
|
|
|
func Value(label string) string {
|
|
|
|
kv := strings.SplitN(label, "=", 2)
|
|
|
|
|
|
|
|
return kv[1]
|
|
|
|
}
|