labels.go 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. package netlabel
  2. import (
  3. "strings"
  4. )
  5. const (
  6. // Prefix constant marks the reserved label space for libnetwork
  7. Prefix = "com.docker.network"
  8. // DriverPrefix constant marks the reserved label space for libnetwork drivers
  9. DriverPrefix = Prefix + ".driver"
  10. // DriverPrivatePrefix constant marks the reserved label space
  11. // for internal libnetwork drivers
  12. DriverPrivatePrefix = DriverPrefix + ".private"
  13. // GenericData constant that helps to identify an option as a Generic constant
  14. GenericData = Prefix + ".generic"
  15. // PortMap constant represents Port Mapping
  16. PortMap = Prefix + ".portmap"
  17. // MacAddress constant represents Mac Address config of a Container
  18. MacAddress = Prefix + ".endpoint.macaddress"
  19. // ExposedPorts constant represents the container's Exposed Ports
  20. ExposedPorts = Prefix + ".endpoint.exposedports"
  21. // DNSServers A list of DNS servers associated with the endpoint
  22. DNSServers = Prefix + ".endpoint.dnsservers"
  23. // EnableIPv6 constant represents enabling IPV6 at network level
  24. EnableIPv6 = Prefix + ".enable_ipv6"
  25. // DriverMTU constant represents the MTU size for the network driver
  26. DriverMTU = DriverPrefix + ".mtu"
  27. // OverlayBindInterface constant represents overlay driver bind interface
  28. OverlayBindInterface = DriverPrefix + ".overlay.bind_interface"
  29. // OverlayNeighborIP constant represents overlay driver neighbor IP
  30. OverlayNeighborIP = DriverPrefix + ".overlay.neighbor_ip"
  31. // OverlayVxlanIDList constant represents a list of VXLAN Ids as csv
  32. OverlayVxlanIDList = DriverPrefix + ".overlay.vxlanid_list"
  33. // Gateway represents the gateway for the network
  34. Gateway = Prefix + ".gateway"
  35. // Internal constant represents that the network is internal which disables default gateway service
  36. Internal = Prefix + ".internal"
  37. // ContainerIfacePrefix can be used to override the interface prefix used inside the container
  38. ContainerIfacePrefix = Prefix + ".container_iface_prefix"
  39. // HostIP is the Source-IP Address used to SNAT container traffic
  40. HostIP = Prefix + ".host_ipv4"
  41. // GlobalKVProvider constant represents the KV provider backend
  42. GlobalKVProvider = DriverPrivatePrefix + "globalkv_provider"
  43. // GlobalKVProviderURL constant represents the KV provider URL
  44. GlobalKVProviderURL = DriverPrivatePrefix + "globalkv_provider_url"
  45. // GlobalKVProviderConfig constant represents the KV provider Config
  46. GlobalKVProviderConfig = DriverPrivatePrefix + "globalkv_provider_config"
  47. // GlobalKVClient constants represents the global kv store client
  48. GlobalKVClient = DriverPrivatePrefix + "globalkv_client"
  49. // LocalKVProvider constant represents the KV provider backend
  50. LocalKVProvider = DriverPrivatePrefix + "localkv_provider"
  51. // LocalKVProviderURL constant represents the KV provider URL
  52. LocalKVProviderURL = DriverPrivatePrefix + "localkv_provider_url"
  53. // LocalKVProviderConfig constant represents the KV provider Config
  54. LocalKVProviderConfig = DriverPrivatePrefix + "localkv_provider_config"
  55. // LocalKVClient constants represents the local kv store client
  56. LocalKVClient = DriverPrivatePrefix + "localkv_client"
  57. )
  58. // MakeKVProvider returns the kvprovider label for the scope
  59. func MakeKVProvider(scope string) string {
  60. return DriverPrivatePrefix + scope + "kv_provider"
  61. }
  62. // MakeKVProviderURL returns the kvprovider url label for the scope
  63. func MakeKVProviderURL(scope string) string {
  64. return DriverPrivatePrefix + scope + "kv_provider_url"
  65. }
  66. // MakeKVProviderConfig returns the kvprovider config label for the scope
  67. func MakeKVProviderConfig(scope string) string {
  68. return DriverPrivatePrefix + scope + "kv_provider_config"
  69. }
  70. // MakeKVClient returns the kv client label for the scope
  71. func MakeKVClient(scope string) string {
  72. return DriverPrivatePrefix + scope + "kv_client"
  73. }
  74. // Key extracts the key portion of the label
  75. func Key(label string) (key string) {
  76. key, _, _ = strings.Cut(label, "=")
  77. return key
  78. }
  79. // Value extracts the value portion of the label
  80. func Value(label string) (value string) {
  81. _, value, _ = strings.Cut(label, "=")
  82. return value
  83. }
  84. // KeyValue decomposes the label in the (key,value) pair
  85. func KeyValue(label string) (key string, value string) {
  86. key, value, _ = strings.Cut(label, "=")
  87. return key, value
  88. }