github.com/Heebron/moby@v0.0.0-20221111184709-6eab4f55faf7/api/types/network/network.go (about)

     1  package network // import "github.com/docker/docker/api/types/network"
     2  import (
     3  	"github.com/docker/docker/api/types/filters"
     4  )
     5  
     6  // Address represents an IP address
     7  type Address struct {
     8  	Addr      string
     9  	PrefixLen int
    10  }
    11  
    12  // IPAM represents IP Address Management
    13  type IPAM struct {
    14  	Driver  string
    15  	Options map[string]string // Per network IPAM driver options
    16  	Config  []IPAMConfig
    17  }
    18  
    19  // IPAMConfig represents IPAM configurations
    20  type IPAMConfig struct {
    21  	Subnet     string            `json:",omitempty"`
    22  	IPRange    string            `json:",omitempty"`
    23  	Gateway    string            `json:",omitempty"`
    24  	AuxAddress map[string]string `json:"AuxiliaryAddresses,omitempty"`
    25  }
    26  
    27  // EndpointIPAMConfig represents IPAM configurations for the endpoint
    28  type EndpointIPAMConfig struct {
    29  	IPv4Address  string   `json:",omitempty"`
    30  	IPv6Address  string   `json:",omitempty"`
    31  	LinkLocalIPs []string `json:",omitempty"`
    32  }
    33  
    34  // Copy makes a copy of the endpoint ipam config
    35  func (cfg *EndpointIPAMConfig) Copy() *EndpointIPAMConfig {
    36  	cfgCopy := *cfg
    37  	cfgCopy.LinkLocalIPs = make([]string, 0, len(cfg.LinkLocalIPs))
    38  	cfgCopy.LinkLocalIPs = append(cfgCopy.LinkLocalIPs, cfg.LinkLocalIPs...)
    39  	return &cfgCopy
    40  }
    41  
    42  // PeerInfo represents one peer of an overlay network
    43  type PeerInfo struct {
    44  	Name string
    45  	IP   string
    46  }
    47  
    48  // EndpointSettings stores the network endpoint details
    49  type EndpointSettings struct {
    50  	// Configurations
    51  	IPAMConfig *EndpointIPAMConfig
    52  	Links      []string
    53  	Aliases    []string
    54  	// Operational data
    55  	NetworkID           string
    56  	EndpointID          string
    57  	Gateway             string
    58  	IPAddress           string
    59  	IPPrefixLen         int
    60  	IPv6Gateway         string
    61  	GlobalIPv6Address   string
    62  	GlobalIPv6PrefixLen int
    63  	MacAddress          string
    64  	DriverOpts          map[string]string
    65  }
    66  
    67  // Task carries the information about one backend task
    68  type Task struct {
    69  	Name       string
    70  	EndpointID string
    71  	EndpointIP string
    72  	Info       map[string]string
    73  }
    74  
    75  // ServiceInfo represents service parameters with the list of service's tasks
    76  type ServiceInfo struct {
    77  	VIP          string
    78  	Ports        []string
    79  	LocalLBIndex int
    80  	Tasks        []Task
    81  }
    82  
    83  // Copy makes a deep copy of `EndpointSettings`
    84  func (es *EndpointSettings) Copy() *EndpointSettings {
    85  	epCopy := *es
    86  	if es.IPAMConfig != nil {
    87  		epCopy.IPAMConfig = es.IPAMConfig.Copy()
    88  	}
    89  
    90  	if es.Links != nil {
    91  		links := make([]string, 0, len(es.Links))
    92  		epCopy.Links = append(links, es.Links...)
    93  	}
    94  
    95  	if es.Aliases != nil {
    96  		aliases := make([]string, 0, len(es.Aliases))
    97  		epCopy.Aliases = append(aliases, es.Aliases...)
    98  	}
    99  	return &epCopy
   100  }
   101  
   102  // NetworkingConfig represents the container's networking configuration for each of its interfaces
   103  // Carries the networking configs specified in the `docker run` and `docker network connect` commands
   104  type NetworkingConfig struct {
   105  	EndpointsConfig map[string]*EndpointSettings // Endpoint configs for each connecting network
   106  }
   107  
   108  // ConfigReference specifies the source which provides a network's configuration
   109  type ConfigReference struct {
   110  	Network string
   111  }
   112  
   113  var acceptedFilters = map[string]bool{
   114  	"dangling": true,
   115  	"driver":   true,
   116  	"id":       true,
   117  	"label":    true,
   118  	"name":     true,
   119  	"scope":    true,
   120  	"type":     true,
   121  }
   122  
   123  // ValidateFilters validates the list of filter args with the available filters.
   124  func ValidateFilters(filter filters.Args) error {
   125  	return filter.Validate(acceptedFilters)
   126  }