github.com/vieux/docker@v0.6.3-0.20161004191708-e097c2a938c7/api/types/swarm/network.go (about) 1 package swarm 2 3 // Endpoint represents an endpoint. 4 type Endpoint struct { 5 Spec EndpointSpec `json:",omitempty"` 6 Ports []PortConfig `json:",omitempty"` 7 VirtualIPs []EndpointVirtualIP `json:",omitempty"` 8 } 9 10 // EndpointSpec represents the spec of an endpoint. 11 type EndpointSpec struct { 12 Mode ResolutionMode `json:",omitempty"` 13 Ports []PortConfig `json:",omitempty"` 14 } 15 16 // ResolutionMode represents a resolution mode. 17 type ResolutionMode string 18 19 const ( 20 // ResolutionModeVIP VIP 21 ResolutionModeVIP ResolutionMode = "vip" 22 // ResolutionModeDNSRR DNSRR 23 ResolutionModeDNSRR ResolutionMode = "dnsrr" 24 ) 25 26 // PortConfig represents the config of a port. 27 type PortConfig struct { 28 Name string `json:",omitempty"` 29 Protocol PortConfigProtocol `json:",omitempty"` 30 // TargetPort is the port inside the container 31 TargetPort uint32 `json:",omitempty"` 32 // PublishedPort is the port on the swarm hosts 33 PublishedPort uint32 `json:",omitempty"` 34 } 35 36 // PortConfigProtocol represents the protocol of a port. 37 type PortConfigProtocol string 38 39 const ( 40 // TODO(stevvooe): These should be used generally, not just for PortConfig. 41 42 // PortConfigProtocolTCP TCP 43 PortConfigProtocolTCP PortConfigProtocol = "tcp" 44 // PortConfigProtocolUDP UDP 45 PortConfigProtocolUDP PortConfigProtocol = "udp" 46 ) 47 48 // EndpointVirtualIP represents the virtual ip of a port. 49 type EndpointVirtualIP struct { 50 NetworkID string `json:",omitempty"` 51 Addr string `json:",omitempty"` 52 } 53 54 // Network represents a network. 55 type Network struct { 56 ID string 57 Meta 58 Spec NetworkSpec `json:",omitempty"` 59 DriverState Driver `json:",omitempty"` 60 IPAMOptions *IPAMOptions `json:",omitempty"` 61 } 62 63 // NetworkSpec represents the spec of a network. 64 type NetworkSpec struct { 65 Annotations 66 DriverConfiguration *Driver `json:",omitempty"` 67 IPv6Enabled bool `json:",omitempty"` 68 Internal bool `json:",omitempty"` 69 Attachable bool `json:",omitempty"` 70 IPAMOptions *IPAMOptions `json:",omitempty"` 71 } 72 73 // NetworkAttachmentConfig represents the configuration of a network attachment. 74 type NetworkAttachmentConfig struct { 75 Target string `json:",omitempty"` 76 Aliases []string `json:",omitempty"` 77 } 78 79 // NetworkAttachment represents a network attachment. 80 type NetworkAttachment struct { 81 Network Network `json:",omitempty"` 82 Addresses []string `json:",omitempty"` 83 } 84 85 // IPAMOptions represents ipam options. 86 type IPAMOptions struct { 87 Driver Driver `json:",omitempty"` 88 Configs []IPAMConfig `json:",omitempty"` 89 } 90 91 // IPAMConfig represents ipam configuration. 92 type IPAMConfig struct { 93 Subnet string `json:",omitempty"` 94 Range string `json:",omitempty"` 95 Gateway string `json:",omitempty"` 96 } 97 98 // Driver represents a network driver. 99 type Driver struct { 100 Name string `json:",omitempty"` 101 Options map[string]string `json:",omitempty"` 102 }