Skip to content

Commit 68bf0e7

Browse files
committed
api/types: migrate EndpointResource to api/types/network
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 5bea0c3 commit 68bf0e7

5 files changed

Lines changed: 39 additions & 32 deletions

File tree

api/types/network/network.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,16 @@ type ServiceInfo struct {
6565
Tasks []Task
6666
}
6767

68+
// EndpointResource contains network resources allocated and used for a
69+
// container in a network.
70+
type EndpointResource struct {
71+
Name string
72+
EndpointID string
73+
MacAddress string
74+
IPv4Address string
75+
IPv6Address string
76+
}
77+
6878
// NetworkingConfig represents the container's networking configuration for each of its interfaces
6979
// Carries the networking configs specified in the `docker run` and `docker network connect` commands
7080
type NetworkingConfig struct {

api/types/types.go

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -425,32 +425,23 @@ type MountPoint struct {
425425

426426
// NetworkResource is the body of the "get network" http response message
427427
type NetworkResource struct {
428-
Name string // Name is the requested name of the network
429-
ID string `json:"Id"` // ID uniquely identifies a network on a single machine
430-
Created time.Time // Created is the time the network created
431-
Scope string // Scope describes the level at which the network exists (e.g. `swarm` for cluster-wide or `local` for machine level)
432-
Driver string // Driver is the Driver name used to create the network (e.g. `bridge`, `overlay`)
433-
EnableIPv6 bool // EnableIPv6 represents whether to enable IPv6
434-
IPAM network.IPAM // IPAM is the network's IP Address Management
435-
Internal bool // Internal represents if the network is used internal only
436-
Attachable bool // Attachable represents if the global scope is manually attachable by regular containers from workers in swarm mode.
437-
Ingress bool // Ingress indicates the network is providing the routing-mesh for the swarm cluster.
438-
ConfigFrom network.ConfigReference // ConfigFrom specifies the source which will provide the configuration for this network.
439-
ConfigOnly bool // ConfigOnly networks are place-holder networks for network configurations to be used by other networks. ConfigOnly networks cannot be used directly to run containers or services.
440-
Containers map[string]EndpointResource // Containers contains endpoints belonging to the network
441-
Options map[string]string // Options holds the network specific options to use for when creating the network
442-
Labels map[string]string // Labels holds metadata specific to the network being created
443-
Peers []network.PeerInfo `json:",omitempty"` // List of peer nodes for an overlay network
444-
Services map[string]network.ServiceInfo `json:",omitempty"`
445-
}
446-
447-
// EndpointResource contains network resources allocated and used for a container in a network
448-
type EndpointResource struct {
449-
Name string
450-
EndpointID string
451-
MacAddress string
452-
IPv4Address string
453-
IPv6Address string
428+
Name string // Name is the requested name of the network
429+
ID string `json:"Id"` // ID uniquely identifies a network on a single machine
430+
Created time.Time // Created is the time the network created
431+
Scope string // Scope describes the level at which the network exists (e.g. `swarm` for cluster-wide or `local` for machine level)
432+
Driver string // Driver is the Driver name used to create the network (e.g. `bridge`, `overlay`)
433+
EnableIPv6 bool // EnableIPv6 represents whether to enable IPv6
434+
IPAM network.IPAM // IPAM is the network's IP Address Management
435+
Internal bool // Internal represents if the network is used internal only
436+
Attachable bool // Attachable represents if the global scope is manually attachable by regular containers from workers in swarm mode.
437+
Ingress bool // Ingress indicates the network is providing the routing-mesh for the swarm cluster.
438+
ConfigFrom network.ConfigReference // ConfigFrom specifies the source which will provide the configuration for this network.
439+
ConfigOnly bool // ConfigOnly networks are place-holder networks for network configurations to be used by other networks. ConfigOnly networks cannot be used directly to run containers or services.
440+
Containers map[string]network.EndpointResource // Containers contains endpoints belonging to the network
441+
Options map[string]string // Options holds the network specific options to use for when creating the network
442+
Labels map[string]string // Labels holds metadata specific to the network being created
443+
Peers []network.PeerInfo `json:",omitempty"` // List of peer nodes for an overlay network
444+
Services map[string]network.ServiceInfo `json:",omitempty"`
454445
}
455446

456447
// NetworkCreate is the expected body of the "create network" http request message

api/types/types_deprecated.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,8 @@ type NetworkConnect = network.ConnectOptions
5454
//
5555
// Deprecated: use [network.DisconnectOptions].
5656
type NetworkDisconnect = network.DisconnectOptions
57+
58+
// EndpointResource contains network resources allocated and used for a container in a network.
59+
//
60+
// Deprecated: use [network.EndpointResource].
61+
type EndpointResource = network.EndpointResource

daemon/network.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ func buildNetworkResource(nw *libnetwork.Network) types.NetworkResource {
618618
Ingress: nw.Ingress(),
619619
ConfigFrom: network.ConfigReference{Network: nw.ConfigFrom()},
620620
ConfigOnly: nw.ConfigOnly(),
621-
Containers: map[string]types.EndpointResource{},
621+
Containers: map[string]network.EndpointResource{},
622622
Options: nw.DriverOptions(),
623623
Labels: nw.Labels(),
624624
Peers: buildPeerInfoResources(nw.Peers()),
@@ -628,8 +628,8 @@ func buildNetworkResource(nw *libnetwork.Network) types.NetworkResource {
628628
// buildContainerAttachments creates a [types.EndpointResource] map of all
629629
// containers attached to the network. It is used when listing networks in
630630
// detailed mode.
631-
func buildContainerAttachments(nw *libnetwork.Network) map[string]types.EndpointResource {
632-
containers := make(map[string]types.EndpointResource)
631+
func buildContainerAttachments(nw *libnetwork.Network) map[string]network.EndpointResource {
632+
containers := make(map[string]network.EndpointResource)
633633
for _, e := range nw.Endpoints() {
634634
ei := e.Info()
635635
if ei == nil {
@@ -754,8 +754,8 @@ func buildIPAMResources(nw *libnetwork.Network) network.IPAM {
754754

755755
// buildEndpointResource combines information from the endpoint and additional
756756
// endpoint-info into a [types.EndpointResource].
757-
func buildEndpointResource(ep *libnetwork.Endpoint, info libnetwork.EndpointInfo) types.EndpointResource {
758-
er := types.EndpointResource{
757+
func buildEndpointResource(ep *libnetwork.Endpoint, info libnetwork.EndpointInfo) network.EndpointResource {
758+
er := network.EndpointResource{
759759
EndpointID: ep.ID(),
760760
Name: ep.Name(),
761761
}

daemon/network/filter_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
"github.com/docker/docker/api/types"
1010
"github.com/docker/docker/api/types/filters"
11+
"github.com/docker/docker/api/types/network"
1112
)
1213

1314
func TestFilterNetworks(t *testing.T) {
@@ -46,7 +47,7 @@ func TestFilterNetworks(t *testing.T) {
4647
Name: "networkwithcontainer",
4748
Driver: "nwc",
4849
Scope: "local",
49-
Containers: map[string]types.EndpointResource{
50+
Containers: map[string]network.EndpointResource{
5051
"customcontainer": {
5152
Name: "customendpoint",
5253
},

0 commit comments

Comments
 (0)