github.com/shishir-a412ed/docker@v1.3.2-0.20180103180333-fda904911d87/api/types/swarm/network.go (about) 1 package swarm 2 3 import ( 4 "github.com/docker/docker/api/types/network" 5 ) 6 7 // Endpoint represents an endpoint. 8 type Endpoint struct { 9 Spec EndpointSpec `json:",omitempty"` 10 Ports []PortConfig `json:",omitempty"` 11 VirtualIPs []EndpointVirtualIP `json:",omitempty"` 12 } 13 14 // EndpointSpec represents the spec of an endpoint. 15 type EndpointSpec struct { 16 Mode ResolutionMode `json:",omitempty"` 17 Ports []PortConfig `json:",omitempty"` 18 } 19 20 // ResolutionMode represents a resolution mode. 21 type ResolutionMode string 22 23 const ( 24 // ResolutionModeVIP VIP 25 ResolutionModeVIP ResolutionMode = "vip" 26 // ResolutionModeDNSRR DNSRR 27 ResolutionModeDNSRR ResolutionMode = "dnsrr" 28 ) 29 30 // PortConfig represents the config of a port. 31 type PortConfig struct { 32 Name string `json:",omitempty"` 33 Protocol PortConfigProtocol `json:",omitempty"` 34 // TargetPort is the port inside the container 35 TargetPort uint32 `json:",omitempty"` 36 // PublishedPort is the port on the swarm hosts 37 PublishedPort uint32 `json:",omitempty"` 38 // PublishMode is the mode in which port is published 39 PublishMode PortConfigPublishMode `json:",omitempty"` 40 } 41 42 // PortConfigPublishMode represents the mode in which the port is to 43 // be published. 44 type PortConfigPublishMode string 45 46 const ( 47 // PortConfigPublishModeIngress is used for ports published 48 // for ingress load balancing using routing mesh. 49 PortConfigPublishModeIngress PortConfigPublishMode = "ingress" 50 // PortConfigPublishModeHost is used for ports published 51 // for direct host level access on the host where the task is running. 52 PortConfigPublishModeHost PortConfigPublishMode = "host" 53 ) 54 55 // PortConfigProtocol represents the protocol of a port. 56 type PortConfigProtocol string 57 58 const ( 59 // TODO(stevvooe): These should be used generally, not just for PortConfig. 60 61 // PortConfigProtocolTCP TCP 62 PortConfigProtocolTCP PortConfigProtocol = "tcp" 63 // PortConfigProtocolUDP UDP 64 PortConfigProtocolUDP PortConfigProtocol = "udp" 65 ) 66 67 // EndpointVirtualIP represents the virtual ip of a port. 68 type EndpointVirtualIP struct { 69 NetworkID string `json:",omitempty"` 70 Addr string `json:",omitempty"` 71 } 72 73 // Network represents a network. 74 type Network struct { 75 ID string 76 Meta 77 Spec NetworkSpec `json:",omitempty"` 78 DriverState Driver `json:",omitempty"` 79 IPAMOptions *IPAMOptions `json:",omitempty"` 80 } 81 82 // NetworkSpec represents the spec of a network. 83 type NetworkSpec struct { 84 Annotations 85 DriverConfiguration *Driver `json:",omitempty"` 86 IPv6Enabled bool `json:",omitempty"` 87 Internal bool `json:",omitempty"` 88 Attachable bool `json:",omitempty"` 89 Ingress bool `json:",omitempty"` 90 IPAMOptions *IPAMOptions `json:",omitempty"` 91 ConfigFrom *network.ConfigReference `json:",omitempty"` 92 Scope string `json:",omitempty"` 93 } 94 95 // NetworkAttachmentConfig represents the configuration of a network attachment. 96 type NetworkAttachmentConfig struct { 97 Target string `json:",omitempty"` 98 Aliases []string `json:",omitempty"` 99 DriverOpts map[string]string `json:",omitempty"` 100 } 101 102 // NetworkAttachment represents a network attachment. 103 type NetworkAttachment struct { 104 Network Network `json:",omitempty"` 105 Addresses []string `json:",omitempty"` 106 } 107 108 // IPAMOptions represents ipam options. 109 type IPAMOptions struct { 110 Driver Driver `json:",omitempty"` 111 Configs []IPAMConfig `json:",omitempty"` 112 } 113 114 // IPAMConfig represents ipam configuration. 115 type IPAMConfig struct { 116 Subnet string `json:",omitempty"` 117 Range string `json:",omitempty"` 118 Gateway string `json:",omitempty"` 119 }