github.com/getong/docker@v1.13.1/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  	// PublishMode is the mode in which port is published
    35  	PublishMode PortConfigPublishMode `json:",omitempty"`
    36  }
    37  
    38  // PortConfigPublishMode represents the mode in which the port is to
    39  // be published.
    40  type PortConfigPublishMode string
    41  
    42  const (
    43  	// PortConfigPublishModeIngress is used for ports published
    44  	// for ingress load balancing using routing mesh.
    45  	PortConfigPublishModeIngress PortConfigPublishMode = "ingress"
    46  	// PortConfigPublishModeHost is used for ports published
    47  	// for direct host level access on the host where the task is running.
    48  	PortConfigPublishModeHost PortConfigPublishMode = "host"
    49  )
    50  
    51  // PortConfigProtocol represents the protocol of a port.
    52  type PortConfigProtocol string
    53  
    54  const (
    55  	// TODO(stevvooe): These should be used generally, not just for PortConfig.
    56  
    57  	// PortConfigProtocolTCP TCP
    58  	PortConfigProtocolTCP PortConfigProtocol = "tcp"
    59  	// PortConfigProtocolUDP UDP
    60  	PortConfigProtocolUDP PortConfigProtocol = "udp"
    61  )
    62  
    63  // EndpointVirtualIP represents the virtual ip of a port.
    64  type EndpointVirtualIP struct {
    65  	NetworkID string `json:",omitempty"`
    66  	Addr      string `json:",omitempty"`
    67  }
    68  
    69  // Network represents a network.
    70  type Network struct {
    71  	ID string
    72  	Meta
    73  	Spec        NetworkSpec  `json:",omitempty"`
    74  	DriverState Driver       `json:",omitempty"`
    75  	IPAMOptions *IPAMOptions `json:",omitempty"`
    76  }
    77  
    78  // NetworkSpec represents the spec of a network.
    79  type NetworkSpec struct {
    80  	Annotations
    81  	DriverConfiguration *Driver      `json:",omitempty"`
    82  	IPv6Enabled         bool         `json:",omitempty"`
    83  	Internal            bool         `json:",omitempty"`
    84  	Attachable          bool         `json:",omitempty"`
    85  	IPAMOptions         *IPAMOptions `json:",omitempty"`
    86  }
    87  
    88  // NetworkAttachmentConfig represents the configuration of a network attachment.
    89  type NetworkAttachmentConfig struct {
    90  	Target  string   `json:",omitempty"`
    91  	Aliases []string `json:",omitempty"`
    92  }
    93  
    94  // NetworkAttachment represents a network attachment.
    95  type NetworkAttachment struct {
    96  	Network   Network  `json:",omitempty"`
    97  	Addresses []string `json:",omitempty"`
    98  }
    99  
   100  // IPAMOptions represents ipam options.
   101  type IPAMOptions struct {
   102  	Driver  Driver       `json:",omitempty"`
   103  	Configs []IPAMConfig `json:",omitempty"`
   104  }
   105  
   106  // IPAMConfig represents ipam configuration.
   107  type IPAMConfig struct {
   108  	Subnet  string `json:",omitempty"`
   109  	Range   string `json:",omitempty"`
   110  	Gateway string `json:",omitempty"`
   111  }