github.com/demonoid81/moby@v0.0.0-20200517203328-62dd8e17c460/api/types/swarm/network.go (about)

     1  package swarm // import "github.com/demonoid81/moby/api/types/swarm"
     2  
     3  import (
     4  	"github.com/demonoid81/moby/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  	// PortConfigProtocolSCTP SCTP
    66  	PortConfigProtocolSCTP PortConfigProtocol = "sctp"
    67  )
    68  
    69  // EndpointVirtualIP represents the virtual ip of a port.
    70  type EndpointVirtualIP struct {
    71  	NetworkID string `json:",omitempty"`
    72  	Addr      string `json:",omitempty"`
    73  }
    74  
    75  // Network represents a network.
    76  type Network struct {
    77  	ID string
    78  	Meta
    79  	Spec        NetworkSpec  `json:",omitempty"`
    80  	DriverState Driver       `json:",omitempty"`
    81  	IPAMOptions *IPAMOptions `json:",omitempty"`
    82  }
    83  
    84  // NetworkSpec represents the spec of a network.
    85  type NetworkSpec struct {
    86  	Annotations
    87  	DriverConfiguration *Driver                  `json:",omitempty"`
    88  	IPv6Enabled         bool                     `json:",omitempty"`
    89  	Internal            bool                     `json:",omitempty"`
    90  	Attachable          bool                     `json:",omitempty"`
    91  	Ingress             bool                     `json:",omitempty"`
    92  	IPAMOptions         *IPAMOptions             `json:",omitempty"`
    93  	ConfigFrom          *network.ConfigReference `json:",omitempty"`
    94  	Scope               string                   `json:",omitempty"`
    95  }
    96  
    97  // NetworkAttachmentConfig represents the configuration of a network attachment.
    98  type NetworkAttachmentConfig struct {
    99  	Target     string            `json:",omitempty"`
   100  	Aliases    []string          `json:",omitempty"`
   101  	DriverOpts map[string]string `json:",omitempty"`
   102  }
   103  
   104  // NetworkAttachment represents a network attachment.
   105  type NetworkAttachment struct {
   106  	Network   Network  `json:",omitempty"`
   107  	Addresses []string `json:",omitempty"`
   108  }
   109  
   110  // IPAMOptions represents ipam options.
   111  type IPAMOptions struct {
   112  	Driver  Driver       `json:",omitempty"`
   113  	Configs []IPAMConfig `json:",omitempty"`
   114  }
   115  
   116  // IPAMConfig represents ipam configuration.
   117  type IPAMConfig struct {
   118  	Subnet  string `json:",omitempty"`
   119  	Range   string `json:",omitempty"`
   120  	Gateway string `json:",omitempty"`
   121  }