Browse code

api/types/network: move `InspectOptions` to client mod

Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>

Austin Vazquez authored on 2025/08/22 10:36:08
Showing 19 changed files
... ...
@@ -45,12 +45,6 @@ type CreateOptions struct {
45 45
 	Labels     map[string]string // Labels holds metadata specific to the network being created.
46 46
 }
47 47
 
48
-// InspectOptions holds parameters to inspect network.
49
-type InspectOptions struct {
50
-	Scope   string
51
-	Verbose bool
52
-}
53
-
54 48
 // ConnectOptions represents the data to be used to connect a container to the
55 49
 // network.
56 50
 type ConnectOptions struct {
... ...
@@ -131,8 +131,8 @@ type NetworkAPIClient interface {
131 131
 	NetworkConnect(ctx context.Context, network, container string, config *network.EndpointSettings) error
132 132
 	NetworkCreate(ctx context.Context, name string, options network.CreateOptions) (network.CreateResponse, error)
133 133
 	NetworkDisconnect(ctx context.Context, network, container string, force bool) error
134
-	NetworkInspect(ctx context.Context, network string, options network.InspectOptions) (network.Inspect, error)
135
-	NetworkInspectWithRaw(ctx context.Context, network string, options network.InspectOptions) (network.Inspect, []byte, error)
134
+	NetworkInspect(ctx context.Context, network string, options InspectOptions) (network.Inspect, error)
135
+	NetworkInspectWithRaw(ctx context.Context, network string, options InspectOptions) (network.Inspect, []byte, error)
136 136
 	NetworkList(ctx context.Context, options NetworkListOptions) ([]network.Summary, error)
137 137
 	NetworkRemove(ctx context.Context, network string) error
138 138
 	NetworksPrune(ctx context.Context, pruneFilter filters.Args) (network.PruneReport, error)
... ...
@@ -11,13 +11,13 @@ import (
11 11
 )
12 12
 
13 13
 // NetworkInspect returns the information for a specific network configured in the docker host.
14
-func (cli *Client) NetworkInspect(ctx context.Context, networkID string, options network.InspectOptions) (network.Inspect, error) {
14
+func (cli *Client) NetworkInspect(ctx context.Context, networkID string, options InspectOptions) (network.Inspect, error) {
15 15
 	networkResource, _, err := cli.NetworkInspectWithRaw(ctx, networkID, options)
16 16
 	return networkResource, err
17 17
 }
18 18
 
19 19
 // NetworkInspectWithRaw returns the information for a specific network configured in the docker host and its raw representation.
20
-func (cli *Client) NetworkInspectWithRaw(ctx context.Context, networkID string, options network.InspectOptions) (network.Inspect, []byte, error) {
20
+func (cli *Client) NetworkInspectWithRaw(ctx context.Context, networkID string, options InspectOptions) (network.Inspect, []byte, error) {
21 21
 	networkID, err := trimID("network", networkID)
22 22
 	if err != nil {
23 23
 		return network.Inspect{}, nil, err
24 24
new file mode 100644
... ...
@@ -0,0 +1,7 @@
0
+package client
1
+
2
+// InspectOptions holds parameters to inspect network.
3
+type InspectOptions struct {
4
+	Scope   string
5
+	Verbose bool
6
+}
... ...
@@ -68,39 +68,39 @@ func TestNetworkInspect(t *testing.T) {
68 68
 
69 69
 	t.Run("empty ID", func(t *testing.T) {
70 70
 		// verify that the client does not create a request if the network-ID/name is empty.
71
-		_, err := client.NetworkInspect(context.Background(), "", network.InspectOptions{})
71
+		_, err := client.NetworkInspect(context.Background(), "", InspectOptions{})
72 72
 		assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument))
73 73
 		assert.Check(t, is.ErrorContains(err, "value is empty"))
74 74
 
75
-		_, err = client.NetworkInspect(context.Background(), "    ", network.InspectOptions{})
75
+		_, err = client.NetworkInspect(context.Background(), "    ", InspectOptions{})
76 76
 		assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument))
77 77
 		assert.Check(t, is.ErrorContains(err, "value is empty"))
78 78
 	})
79 79
 	t.Run("no options", func(t *testing.T) {
80
-		r, err := client.NetworkInspect(context.Background(), "network_id", network.InspectOptions{})
80
+		r, err := client.NetworkInspect(context.Background(), "network_id", InspectOptions{})
81 81
 		assert.NilError(t, err)
82 82
 		assert.Check(t, is.Equal(r.Name, "mynetwork"))
83 83
 	})
84 84
 	t.Run("verbose", func(t *testing.T) {
85
-		r, err := client.NetworkInspect(context.Background(), "network_id", network.InspectOptions{Verbose: true})
85
+		r, err := client.NetworkInspect(context.Background(), "network_id", InspectOptions{Verbose: true})
86 86
 		assert.NilError(t, err)
87 87
 		assert.Check(t, is.Equal(r.Name, "mynetwork"))
88 88
 		_, ok := r.Services["web"]
89 89
 		assert.Check(t, ok, "expected service `web` missing in the verbose output")
90 90
 	})
91 91
 	t.Run("global scope", func(t *testing.T) {
92
-		_, err := client.NetworkInspect(context.Background(), "network_id", network.InspectOptions{Scope: "global"})
92
+		_, err := client.NetworkInspect(context.Background(), "network_id", InspectOptions{Scope: "global"})
93 93
 		assert.Check(t, is.ErrorContains(err, "Error: No such network: network_id"))
94 94
 		assert.Check(t, is.ErrorType(err, cerrdefs.IsNotFound))
95 95
 	})
96 96
 	t.Run("unknown network", func(t *testing.T) {
97
-		_, err := client.NetworkInspect(context.Background(), "unknown", network.InspectOptions{})
97
+		_, err := client.NetworkInspect(context.Background(), "unknown", InspectOptions{})
98 98
 		assert.Check(t, is.ErrorContains(err, "Error: No such network: unknown"))
99 99
 		assert.Check(t, is.ErrorType(err, cerrdefs.IsNotFound))
100 100
 	})
101 101
 	t.Run("server error", func(t *testing.T) {
102 102
 		// Just testing that an internal server error is converted correctly by the client
103
-		_, err := client.NetworkInspect(context.Background(), "test-500-response", network.InspectOptions{})
103
+		_, err := client.NetworkInspect(context.Background(), "test-500-response", InspectOptions{})
104 104
 		assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
105 105
 	})
106 106
 }
... ...
@@ -22,6 +22,7 @@ import (
22 22
 	"github.com/moby/moby/api/types/container"
23 23
 	"github.com/moby/moby/api/types/network"
24 24
 	"github.com/moby/moby/api/types/swarm"
25
+	"github.com/moby/moby/client"
25 26
 	"github.com/moby/moby/v2/integration-cli/checker"
26 27
 	"github.com/moby/moby/v2/integration-cli/daemon"
27 28
 	"github.com/moby/moby/v2/testutil"
... ...
@@ -1025,11 +1026,11 @@ func (s *DockerSwarmSuite) TestAPINetworkInspectWithScope(c *testing.T) {
1025 1025
 	resp, err := apiclient.NetworkCreate(ctx, name, network.CreateOptions{Driver: "overlay"})
1026 1026
 	assert.NilError(c, err)
1027 1027
 
1028
-	nw, err := apiclient.NetworkInspect(ctx, name, network.InspectOptions{})
1028
+	nw, err := apiclient.NetworkInspect(ctx, name, client.InspectOptions{})
1029 1029
 	assert.NilError(c, err)
1030 1030
 	assert.Check(c, is.Equal("swarm", nw.Scope))
1031 1031
 	assert.Check(c, is.Equal(resp.ID, nw.ID))
1032 1032
 
1033
-	_, err = apiclient.NetworkInspect(ctx, name, network.InspectOptions{Scope: "local"})
1033
+	_, err = apiclient.NetworkInspect(ctx, name, client.InspectOptions{Scope: "local"})
1034 1034
 	assert.Check(c, is.ErrorType(err, cerrdefs.IsNotFound))
1035 1035
 }
... ...
@@ -10,7 +10,7 @@ import (
10 10
 	"time"
11 11
 
12 12
 	containertypes "github.com/moby/moby/api/types/container"
13
-	"github.com/moby/moby/api/types/network"
13
+	"github.com/moby/moby/client"
14 14
 	realcontainer "github.com/moby/moby/v2/daemon/container"
15 15
 	"github.com/moby/moby/v2/integration/internal/container"
16 16
 	"github.com/moby/moby/v2/testutil"
... ...
@@ -153,7 +153,7 @@ func TestDaemonHostGatewayIP(t *testing.T) {
153 153
 	assert.NilError(t, err)
154 154
 	assert.Assert(t, is.Len(res.Stderr(), 0))
155 155
 	assert.Equal(t, 0, res.ExitCode)
156
-	inspect, err := c.NetworkInspect(ctx, "bridge", network.InspectOptions{})
156
+	inspect, err := c.NetworkInspect(ctx, "bridge", client.InspectOptions{})
157 157
 	assert.NilError(t, err)
158 158
 	assert.Check(t, is.Contains(res.Stdout(), inspect.IPAM.Config[0].Gateway))
159 159
 	c.ContainerRemove(ctx, cID, containertypes.RemoveOptions{Force: true})
... ...
@@ -9,6 +9,7 @@ import (
9 9
 
10 10
 	"github.com/moby/moby/api/types/network"
11 11
 	swarmtypes "github.com/moby/moby/api/types/swarm"
12
+	"github.com/moby/moby/client"
12 13
 	"github.com/moby/moby/v2/daemon/libnetwork/nlwrap"
13 14
 	"github.com/moby/moby/v2/integration/internal/testutils/networking"
14 15
 	"github.com/moby/moby/v2/testutil"
... ...
@@ -418,7 +419,7 @@ func testDefaultBridgeIPAM(ctx context.Context, t *testing.T, tc defaultBridgeIP
418 418
 			c := d.NewClientT(t)
419 419
 			defer c.Close()
420 420
 
421
-			insp, err := c.NetworkInspect(ctx, network.NetworkBridge, network.InspectOptions{})
421
+			insp, err := c.NetworkInspect(ctx, network.NetworkBridge, client.InspectOptions{})
422 422
 			assert.NilError(t, err)
423 423
 			expIPAMConfig := slices.Clone(tc.expIPAMConfig)
424 424
 			for i := range expIPAMConfig {
... ...
@@ -3,15 +3,14 @@ package network
3 3
 import (
4 4
 	"context"
5 5
 
6
-	"github.com/moby/moby/api/types/network"
7 6
 	"github.com/moby/moby/client"
8 7
 	"gotest.tools/v3/poll"
9 8
 )
10 9
 
11 10
 // IsRemoved verifies the network is removed.
12
-func IsRemoved(ctx context.Context, client client.NetworkAPIClient, networkID string) func(log poll.LogT) poll.Result {
11
+func IsRemoved(ctx context.Context, apiClient client.NetworkAPIClient, networkID string) func(log poll.LogT) poll.Result {
13 12
 	return func(log poll.LogT) poll.Result {
14
-		_, err := client.NetworkInspect(ctx, networkID, network.InspectOptions{})
13
+		_, err := apiClient.NetworkInspect(ctx, networkID, client.InspectOptions{})
15 14
 		if err == nil {
16 15
 			return poll.Continue("waiting for network %s to be removed", networkID)
17 16
 		}
... ...
@@ -12,6 +12,7 @@ import (
12 12
 	containertypes "github.com/moby/moby/api/types/container"
13 13
 	networktypes "github.com/moby/moby/api/types/network"
14 14
 	"github.com/moby/moby/api/types/versions"
15
+	"github.com/moby/moby/client"
15 16
 	"github.com/moby/moby/v2/daemon/libnetwork/drivers/bridge"
16 17
 	"github.com/moby/moby/v2/daemon/libnetwork/netlabel"
17 18
 	"github.com/moby/moby/v2/daemon/libnetwork/nlwrap"
... ...
@@ -64,7 +65,7 @@ func TestCreateWithIPv6DefaultsToULAPrefix(t *testing.T) {
64 64
 	network.CreateNoError(ctx, t, apiClient, nwName, network.WithIPv6())
65 65
 	defer network.RemoveNoError(ctx, t, apiClient, nwName)
66 66
 
67
-	nw, err := apiClient.NetworkInspect(ctx, "testnetula", networktypes.InspectOptions{})
67
+	nw, err := apiClient.NetworkInspect(ctx, "testnetula", client.InspectOptions{})
68 68
 	assert.NilError(t, err)
69 69
 
70 70
 	for _, ipam := range nw.IPAM.Config {
... ...
@@ -91,7 +92,7 @@ func TestCreateWithIPv6WithoutEnableIPv6Flag(t *testing.T) {
91 91
 	network.CreateNoError(ctx, t, apiClient, nwName)
92 92
 	defer network.RemoveNoError(ctx, t, apiClient, nwName)
93 93
 
94
-	nw, err := apiClient.NetworkInspect(ctx, "testnetula", networktypes.InspectOptions{})
94
+	nw, err := apiClient.NetworkInspect(ctx, "testnetula", client.InspectOptions{})
95 95
 	assert.NilError(t, err)
96 96
 
97 97
 	for _, ipam := range nw.IPAM.Config {
... ...
@@ -136,7 +137,7 @@ func TestDefaultIPvOptOverride(t *testing.T) {
136 136
 					network.CreateNoError(ctx, t, c, netName, nopts...)
137 137
 					defer network.RemoveNoError(ctx, t, c, netName)
138 138
 
139
-					insp, err := c.NetworkInspect(ctx, netName, networktypes.InspectOptions{})
139
+					insp, err := c.NetworkInspect(ctx, netName, client.InspectOptions{})
140 140
 					assert.NilError(t, err)
141 141
 					t.Log("override4", override4, "override6", override6, "->", insp.Options)
142 142
 
... ...
@@ -3,7 +3,7 @@ package network
3 3
 import (
4 4
 	"testing"
5 5
 
6
-	networktypes "github.com/moby/moby/api/types/network"
6
+	"github.com/moby/moby/client"
7 7
 	"github.com/moby/moby/v2/integration/internal/network"
8 8
 	"github.com/moby/moby/v2/integration/internal/swarm"
9 9
 	"github.com/moby/moby/v2/testutil"
... ...
@@ -41,33 +41,33 @@ func TestInspectNetwork(t *testing.T) {
41 41
 	tests := []struct {
42 42
 		name    string
43 43
 		network string
44
-		opts    networktypes.InspectOptions
44
+		opts    client.InspectOptions
45 45
 	}{
46 46
 		{
47 47
 			name:    "full network id",
48 48
 			network: overlayID,
49
-			opts: networktypes.InspectOptions{
49
+			opts: client.InspectOptions{
50 50
 				Verbose: true,
51 51
 			},
52 52
 		},
53 53
 		{
54 54
 			name:    "partial network id",
55 55
 			network: overlayID[0:11],
56
-			opts: networktypes.InspectOptions{
56
+			opts: client.InspectOptions{
57 57
 				Verbose: true,
58 58
 			},
59 59
 		},
60 60
 		{
61 61
 			name:    "network name",
62 62
 			network: networkName,
63
-			opts: networktypes.InspectOptions{
63
+			opts: client.InspectOptions{
64 64
 				Verbose: true,
65 65
 			},
66 66
 		},
67 67
 		{
68 68
 			name:    "network name and swarm scope",
69 69
 			network: networkName,
70
-			opts: networktypes.InspectOptions{
70
+			opts: client.InspectOptions{
71 71
 				Verbose: true,
72 72
 				Scope:   "swarm",
73 73
 			},
... ...
@@ -89,7 +89,7 @@ func TestHostIPv4BridgeLabel(t *testing.T) {
89 89
 		network.WithOption("com.docker.network.bridge.name", bridgeName),
90 90
 	)
91 91
 	defer network.RemoveNoError(ctx, t, c, bridgeName)
92
-	out, err := c.NetworkInspect(ctx, bridgeName, networktypes.InspectOptions{Verbose: true})
92
+	out, err := c.NetworkInspect(ctx, bridgeName, client.InspectOptions{Verbose: true})
93 93
 	assert.NilError(t, err)
94 94
 	assert.Assert(t, len(out.IPAM.Config) > 0)
95 95
 	// Make sure the SNAT rule exists
... ...
@@ -45,7 +45,7 @@ func TestDaemonRestartWithLiveRestore(t *testing.T) {
45 45
 	defer c.Close()
46 46
 
47 47
 	// Verify bridge network's subnet
48
-	out, err := c.NetworkInspect(ctx, "bridge", networktypes.InspectOptions{})
48
+	out, err := c.NetworkInspect(ctx, "bridge", client.InspectOptions{})
49 49
 	assert.NilError(t, err)
50 50
 	subnet := out.IPAM.Config[0].Subnet
51 51
 
... ...
@@ -55,7 +55,7 @@ func TestDaemonRestartWithLiveRestore(t *testing.T) {
55 55
 		"--default-address-pool", "base=175.33.0.0/16,size=24",
56 56
 	)
57 57
 
58
-	out1, err := c.NetworkInspect(ctx, "bridge", networktypes.InspectOptions{})
58
+	out1, err := c.NetworkInspect(ctx, "bridge", client.InspectOptions{})
59 59
 	assert.NilError(t, err)
60 60
 	// Make sure docker0 doesn't get override with new IP in live restore case
61 61
 	assert.Equal(t, out1.IPAM.Config[0].Subnet, subnet)
... ...
@@ -82,7 +82,7 @@ func TestDaemonDefaultNetworkPools(t *testing.T) {
82 82
 	defer c.Close()
83 83
 
84 84
 	// Verify bridge network's subnet
85
-	out, err := c.NetworkInspect(ctx, "bridge", networktypes.InspectOptions{})
85
+	out, err := c.NetworkInspect(ctx, "bridge", client.InspectOptions{})
86 86
 	assert.NilError(t, err)
87 87
 	assert.Equal(t, out.IPAM.Config[0].Subnet, "175.30.0.0/16")
88 88
 
... ...
@@ -92,7 +92,7 @@ func TestDaemonDefaultNetworkPools(t *testing.T) {
92 92
 		network.WithDriver("bridge"),
93 93
 	)
94 94
 	defer network.RemoveNoError(ctx, t, c, name)
95
-	out, err = c.NetworkInspect(ctx, name, networktypes.InspectOptions{})
95
+	out, err = c.NetworkInspect(ctx, name, client.InspectOptions{})
96 96
 	assert.NilError(t, err)
97 97
 	assert.Check(t, is.Equal(out.IPAM.Config[0].Subnet, "175.33.0.0/24"))
98 98
 
... ...
@@ -102,7 +102,7 @@ func TestDaemonDefaultNetworkPools(t *testing.T) {
102 102
 		network.WithDriver("bridge"),
103 103
 	)
104 104
 	defer network.RemoveNoError(ctx, t, c, name)
105
-	out, err = c.NetworkInspect(ctx, name, networktypes.InspectOptions{})
105
+	out, err = c.NetworkInspect(ctx, name, client.InspectOptions{})
106 106
 	assert.NilError(t, err)
107 107
 	assert.Check(t, is.Equal(out.IPAM.Config[0].Subnet, "175.33.1.0/24"))
108 108
 }
... ...
@@ -127,7 +127,7 @@ func TestDaemonRestartWithExistingNetwork(t *testing.T) {
127 127
 	defer network.RemoveNoError(ctx, t, c, name)
128 128
 
129 129
 	// Verify bridge network's subnet
130
-	out, err := c.NetworkInspect(ctx, name, networktypes.InspectOptions{})
130
+	out, err := c.NetworkInspect(ctx, name, client.InspectOptions{})
131 131
 	assert.NilError(t, err)
132 132
 	networkip := out.IPAM.Config[0].Subnet
133 133
 
... ...
@@ -137,7 +137,7 @@ func TestDaemonRestartWithExistingNetwork(t *testing.T) {
137 137
 		"--default-address-pool", "base=175.33.0.0/16,size=24")
138 138
 	defer delInterface(ctx, t, "docker0")
139 139
 
140
-	out1, err := c.NetworkInspect(ctx, name, networktypes.InspectOptions{})
140
+	out1, err := c.NetworkInspect(ctx, name, client.InspectOptions{})
141 141
 	assert.NilError(t, err)
142 142
 	assert.Equal(t, out1.IPAM.Config[0].Subnet, networkip)
143 143
 }
... ...
@@ -163,7 +163,7 @@ func TestDaemonRestartWithExistingNetworkWithDefaultPoolRange(t *testing.T) {
163 163
 	defer network.RemoveNoError(ctx, t, c, name)
164 164
 
165 165
 	// Verify bridge network's subnet
166
-	out, err := c.NetworkInspect(ctx, name, networktypes.InspectOptions{})
166
+	out, err := c.NetworkInspect(ctx, name, client.InspectOptions{})
167 167
 	assert.NilError(t, err)
168 168
 	networkip := out.IPAM.Config[0].Subnet
169 169
 
... ...
@@ -173,7 +173,7 @@ func TestDaemonRestartWithExistingNetworkWithDefaultPoolRange(t *testing.T) {
173 173
 		network.WithDriver("bridge"),
174 174
 	)
175 175
 	defer network.RemoveNoError(ctx, t, c, name)
176
-	out, err = c.NetworkInspect(ctx, name, networktypes.InspectOptions{})
176
+	out, err = c.NetworkInspect(ctx, name, client.InspectOptions{})
177 177
 	assert.NilError(t, err)
178 178
 	networkip2 := out.IPAM.Config[0].Subnet
179 179
 
... ...
@@ -190,7 +190,7 @@ func TestDaemonRestartWithExistingNetworkWithDefaultPoolRange(t *testing.T) {
190 190
 		network.WithDriver("bridge"),
191 191
 	)
192 192
 	defer network.RemoveNoError(ctx, t, c, name)
193
-	out1, err := c.NetworkInspect(ctx, name, networktypes.InspectOptions{})
193
+	out1, err := c.NetworkInspect(ctx, name, client.InspectOptions{})
194 194
 	assert.NilError(t, err)
195 195
 
196 196
 	assert.Check(t, out1.IPAM.Config[0].Subnet != networkip)
... ...
@@ -217,7 +217,7 @@ func TestDaemonWithBipAndDefaultNetworkPool(t *testing.T) {
217 217
 	defer c.Close()
218 218
 
219 219
 	// Verify bridge network's subnet
220
-	out, err := c.NetworkInspect(ctx, "bridge", networktypes.InspectOptions{})
220
+	out, err := c.NetworkInspect(ctx, "bridge", client.InspectOptions{})
221 221
 	assert.NilError(t, err)
222 222
 	// Make sure BIP IP doesn't get override with new default address pool .
223 223
 	assert.Equal(t, out.IPAM.Config[0].Subnet, "172.60.0.0/16")
... ...
@@ -297,7 +297,7 @@ func TestServiceRemoveKeepsIngressNetwork(t *testing.T) {
297 297
 
298 298
 	// Ensure that "ingress" is not removed or corrupted
299 299
 	time.Sleep(10 * time.Second)
300
-	netInfo, err := c.NetworkInspect(ctx, ingressNet, networktypes.InspectOptions{
300
+	netInfo, err := c.NetworkInspect(ctx, ingressNet, client.InspectOptions{
301 301
 		Verbose: true,
302 302
 		Scope:   "swarm",
303 303
 	})
... ...
@@ -309,9 +309,9 @@ func TestServiceRemoveKeepsIngressNetwork(t *testing.T) {
309 309
 }
310 310
 
311 311
 //nolint:unused // for some reason, the "unused" linter marks this function as "unused"
312
-func swarmIngressReady(ctx context.Context, client client.NetworkAPIClient) func(log poll.LogT) poll.Result {
312
+func swarmIngressReady(ctx context.Context, apiClient client.NetworkAPIClient) func(log poll.LogT) poll.Result {
313 313
 	return func(log poll.LogT) poll.Result {
314
-		netInfo, err := client.NetworkInspect(ctx, ingressNet, networktypes.InspectOptions{
314
+		netInfo, err := apiClient.NetworkInspect(ctx, ingressNet, client.InspectOptions{
315 315
 			Verbose: true,
316 316
 			Scope:   "swarm",
317 317
 		})
... ...
@@ -443,7 +443,7 @@ func TestServiceWithDefaultAddressPoolInit(t *testing.T) {
443 443
 	_, _, err := cli.ServiceInspectWithRaw(ctx, serviceID, swarmtypes.ServiceInspectOptions{})
444 444
 	assert.NilError(t, err)
445 445
 
446
-	out, err := cli.NetworkInspect(ctx, overlayID, networktypes.InspectOptions{Verbose: true})
446
+	out, err := cli.NetworkInspect(ctx, overlayID, client.InspectOptions{Verbose: true})
447 447
 	assert.NilError(t, err)
448 448
 	t.Logf("%s: NetworkInspect: %+v", t.Name(), out)
449 449
 	assert.Assert(t, len(out.IPAM.Config) > 0)
... ...
@@ -454,7 +454,7 @@ func TestServiceWithDefaultAddressPoolInit(t *testing.T) {
454 454
 	assert.Equal(t, out.IPAM.Config[0].Subnet, "20.20.1.0/24")
455 455
 
456 456
 	// Also inspect ingress network and make sure its in the same subnet
457
-	out, err = cli.NetworkInspect(ctx, "ingress", networktypes.InspectOptions{Verbose: true})
457
+	out, err = cli.NetworkInspect(ctx, "ingress", client.InspectOptions{Verbose: true})
458 458
 	assert.NilError(t, err)
459 459
 	assert.Assert(t, len(out.IPAM.Config) > 0)
460 460
 	assert.Equal(t, out.IPAM.Config[0].Subnet, "20.20.0.0/24")
... ...
@@ -584,7 +584,7 @@ func TestAccessToPublishedPort(t *testing.T) {
584 584
 			// Use the default bridge addresses as host addresses (like "host-gateway", but
585 585
 			// there's no way to tell wget to prefer ipv4/ipv6 transport, so just use the
586 586
 			// addresses directly).
587
-			insp, err := c.NetworkInspect(ctx, "bridge", networktypes.InspectOptions{})
587
+			insp, err := c.NetworkInspect(ctx, "bridge", client.InspectOptions{})
588 588
 			assert.NilError(t, err)
589 589
 			for _, ipamCfg := range insp.IPAM.Config {
590 590
 				ipv := "ipv4"
... ...
@@ -1821,7 +1821,7 @@ func TestNetworkInspectGateway(t *testing.T) {
1821 1821
 	assert.NilError(t, err)
1822 1822
 	defer network.RemoveNoError(ctx, t, c, netName)
1823 1823
 
1824
-	insp, err := c.NetworkInspect(ctx, nid, networktypes.InspectOptions{})
1824
+	insp, err := c.NetworkInspect(ctx, nid, client.InspectOptions{})
1825 1825
 	assert.NilError(t, err)
1826 1826
 	for _, ipamCfg := range insp.IPAM.Config {
1827 1827
 		_, err := netip.ParseAddr(ipamCfg.Gateway)
... ...
@@ -6,7 +6,6 @@ import (
6 6
 
7 7
 	"github.com/moby/moby/api/types/container"
8 8
 	"github.com/moby/moby/api/types/filters"
9
-	networktypes "github.com/moby/moby/api/types/network"
10 9
 	swarmtypes "github.com/moby/moby/api/types/swarm"
11 10
 	"github.com/moby/moby/client"
12 11
 	"github.com/moby/moby/v2/integration/internal/network"
... ...
@@ -222,7 +221,7 @@ func TestServiceUpdateNetwork(t *testing.T) {
222 222
 
223 223
 	poll.WaitOn(t, swarm.RunningTasksCount(ctx, cli, serviceID, instances), swarm.ServicePoll)
224 224
 	service := getService(ctx, t, cli, serviceID)
225
-	netInfo, err := cli.NetworkInspect(ctx, testNet, networktypes.InspectOptions{
225
+	netInfo, err := cli.NetworkInspect(ctx, testNet, client.InspectOptions{
226 226
 		Verbose: true,
227 227
 		Scope:   "swarm",
228 228
 	})
... ...
@@ -235,7 +234,7 @@ func TestServiceUpdateNetwork(t *testing.T) {
235 235
 	assert.NilError(t, err)
236 236
 	poll.WaitOn(t, serviceIsUpdated(ctx, cli, serviceID), swarm.ServicePoll)
237 237
 
238
-	netInfo, err = cli.NetworkInspect(ctx, testNet, networktypes.InspectOptions{
238
+	netInfo, err = cli.NetworkInspect(ctx, testNet, client.InspectOptions{
239 239
 		Verbose: true,
240 240
 		Scope:   "swarm",
241 241
 	})
... ...
@@ -45,12 +45,6 @@ type CreateOptions struct {
45 45
 	Labels     map[string]string // Labels holds metadata specific to the network being created.
46 46
 }
47 47
 
48
-// InspectOptions holds parameters to inspect network.
49
-type InspectOptions struct {
50
-	Scope   string
51
-	Verbose bool
52
-}
53
-
54 48
 // ConnectOptions represents the data to be used to connect a container to the
55 49
 // network.
56 50
 type ConnectOptions struct {
... ...
@@ -131,8 +131,8 @@ type NetworkAPIClient interface {
131 131
 	NetworkConnect(ctx context.Context, network, container string, config *network.EndpointSettings) error
132 132
 	NetworkCreate(ctx context.Context, name string, options network.CreateOptions) (network.CreateResponse, error)
133 133
 	NetworkDisconnect(ctx context.Context, network, container string, force bool) error
134
-	NetworkInspect(ctx context.Context, network string, options network.InspectOptions) (network.Inspect, error)
135
-	NetworkInspectWithRaw(ctx context.Context, network string, options network.InspectOptions) (network.Inspect, []byte, error)
134
+	NetworkInspect(ctx context.Context, network string, options InspectOptions) (network.Inspect, error)
135
+	NetworkInspectWithRaw(ctx context.Context, network string, options InspectOptions) (network.Inspect, []byte, error)
136 136
 	NetworkList(ctx context.Context, options NetworkListOptions) ([]network.Summary, error)
137 137
 	NetworkRemove(ctx context.Context, network string) error
138 138
 	NetworksPrune(ctx context.Context, pruneFilter filters.Args) (network.PruneReport, error)
... ...
@@ -11,13 +11,13 @@ import (
11 11
 )
12 12
 
13 13
 // NetworkInspect returns the information for a specific network configured in the docker host.
14
-func (cli *Client) NetworkInspect(ctx context.Context, networkID string, options network.InspectOptions) (network.Inspect, error) {
14
+func (cli *Client) NetworkInspect(ctx context.Context, networkID string, options InspectOptions) (network.Inspect, error) {
15 15
 	networkResource, _, err := cli.NetworkInspectWithRaw(ctx, networkID, options)
16 16
 	return networkResource, err
17 17
 }
18 18
 
19 19
 // NetworkInspectWithRaw returns the information for a specific network configured in the docker host and its raw representation.
20
-func (cli *Client) NetworkInspectWithRaw(ctx context.Context, networkID string, options network.InspectOptions) (network.Inspect, []byte, error) {
20
+func (cli *Client) NetworkInspectWithRaw(ctx context.Context, networkID string, options InspectOptions) (network.Inspect, []byte, error) {
21 21
 	networkID, err := trimID("network", networkID)
22 22
 	if err != nil {
23 23
 		return network.Inspect{}, nil, err
24 24
new file mode 100644
... ...
@@ -0,0 +1,7 @@
0
+package client
1
+
2
+// InspectOptions holds parameters to inspect network.
3
+type InspectOptions struct {
4
+	Scope   string
5
+	Verbose bool
6
+}