mirror of
https://github.com/moby/moby.git
synced 2026-08-03 22:51:03 +00:00
api/types/network: move InspectOptions to client mod
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
This commit is contained in:
@@ -45,12 +45,6 @@ type CreateOptions struct {
|
||||
Labels map[string]string // Labels holds metadata specific to the network being created.
|
||||
}
|
||||
|
||||
// InspectOptions holds parameters to inspect network.
|
||||
type InspectOptions struct {
|
||||
Scope string
|
||||
Verbose bool
|
||||
}
|
||||
|
||||
// ConnectOptions represents the data to be used to connect a container to the
|
||||
// network.
|
||||
type ConnectOptions struct {
|
||||
|
||||
@@ -131,8 +131,8 @@ type NetworkAPIClient interface {
|
||||
NetworkConnect(ctx context.Context, network, container string, config *network.EndpointSettings) error
|
||||
NetworkCreate(ctx context.Context, name string, options network.CreateOptions) (network.CreateResponse, error)
|
||||
NetworkDisconnect(ctx context.Context, network, container string, force bool) error
|
||||
NetworkInspect(ctx context.Context, network string, options network.InspectOptions) (network.Inspect, error)
|
||||
NetworkInspectWithRaw(ctx context.Context, network string, options network.InspectOptions) (network.Inspect, []byte, error)
|
||||
NetworkInspect(ctx context.Context, network string, options InspectOptions) (network.Inspect, error)
|
||||
NetworkInspectWithRaw(ctx context.Context, network string, options InspectOptions) (network.Inspect, []byte, error)
|
||||
NetworkList(ctx context.Context, options NetworkListOptions) ([]network.Summary, error)
|
||||
NetworkRemove(ctx context.Context, network string) error
|
||||
NetworksPrune(ctx context.Context, pruneFilter filters.Args) (network.PruneReport, error)
|
||||
|
||||
@@ -11,13 +11,13 @@ import (
|
||||
)
|
||||
|
||||
// NetworkInspect returns the information for a specific network configured in the docker host.
|
||||
func (cli *Client) NetworkInspect(ctx context.Context, networkID string, options network.InspectOptions) (network.Inspect, error) {
|
||||
func (cli *Client) NetworkInspect(ctx context.Context, networkID string, options InspectOptions) (network.Inspect, error) {
|
||||
networkResource, _, err := cli.NetworkInspectWithRaw(ctx, networkID, options)
|
||||
return networkResource, err
|
||||
}
|
||||
|
||||
// NetworkInspectWithRaw returns the information for a specific network configured in the docker host and its raw representation.
|
||||
func (cli *Client) NetworkInspectWithRaw(ctx context.Context, networkID string, options network.InspectOptions) (network.Inspect, []byte, error) {
|
||||
func (cli *Client) NetworkInspectWithRaw(ctx context.Context, networkID string, options InspectOptions) (network.Inspect, []byte, error) {
|
||||
networkID, err := trimID("network", networkID)
|
||||
if err != nil {
|
||||
return network.Inspect{}, nil, err
|
||||
|
||||
7
client/network_inspect_opts.go
Normal file
7
client/network_inspect_opts.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package client
|
||||
|
||||
// InspectOptions holds parameters to inspect network.
|
||||
type InspectOptions struct {
|
||||
Scope string
|
||||
Verbose bool
|
||||
}
|
||||
@@ -68,39 +68,39 @@ func TestNetworkInspect(t *testing.T) {
|
||||
|
||||
t.Run("empty ID", func(t *testing.T) {
|
||||
// verify that the client does not create a request if the network-ID/name is empty.
|
||||
_, err := client.NetworkInspect(context.Background(), "", network.InspectOptions{})
|
||||
_, err := client.NetworkInspect(context.Background(), "", InspectOptions{})
|
||||
assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument))
|
||||
assert.Check(t, is.ErrorContains(err, "value is empty"))
|
||||
|
||||
_, err = client.NetworkInspect(context.Background(), " ", network.InspectOptions{})
|
||||
_, err = client.NetworkInspect(context.Background(), " ", InspectOptions{})
|
||||
assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument))
|
||||
assert.Check(t, is.ErrorContains(err, "value is empty"))
|
||||
})
|
||||
t.Run("no options", func(t *testing.T) {
|
||||
r, err := client.NetworkInspect(context.Background(), "network_id", network.InspectOptions{})
|
||||
r, err := client.NetworkInspect(context.Background(), "network_id", InspectOptions{})
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal(r.Name, "mynetwork"))
|
||||
})
|
||||
t.Run("verbose", func(t *testing.T) {
|
||||
r, err := client.NetworkInspect(context.Background(), "network_id", network.InspectOptions{Verbose: true})
|
||||
r, err := client.NetworkInspect(context.Background(), "network_id", InspectOptions{Verbose: true})
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal(r.Name, "mynetwork"))
|
||||
_, ok := r.Services["web"]
|
||||
assert.Check(t, ok, "expected service `web` missing in the verbose output")
|
||||
})
|
||||
t.Run("global scope", func(t *testing.T) {
|
||||
_, err := client.NetworkInspect(context.Background(), "network_id", network.InspectOptions{Scope: "global"})
|
||||
_, err := client.NetworkInspect(context.Background(), "network_id", InspectOptions{Scope: "global"})
|
||||
assert.Check(t, is.ErrorContains(err, "Error: No such network: network_id"))
|
||||
assert.Check(t, is.ErrorType(err, cerrdefs.IsNotFound))
|
||||
})
|
||||
t.Run("unknown network", func(t *testing.T) {
|
||||
_, err := client.NetworkInspect(context.Background(), "unknown", network.InspectOptions{})
|
||||
_, err := client.NetworkInspect(context.Background(), "unknown", InspectOptions{})
|
||||
assert.Check(t, is.ErrorContains(err, "Error: No such network: unknown"))
|
||||
assert.Check(t, is.ErrorType(err, cerrdefs.IsNotFound))
|
||||
})
|
||||
t.Run("server error", func(t *testing.T) {
|
||||
// Just testing that an internal server error is converted correctly by the client
|
||||
_, err := client.NetworkInspect(context.Background(), "test-500-response", network.InspectOptions{})
|
||||
_, err := client.NetworkInspect(context.Background(), "test-500-response", InspectOptions{})
|
||||
assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
"github.com/moby/moby/api/types/container"
|
||||
"github.com/moby/moby/api/types/network"
|
||||
"github.com/moby/moby/api/types/swarm"
|
||||
"github.com/moby/moby/client"
|
||||
"github.com/moby/moby/v2/integration-cli/checker"
|
||||
"github.com/moby/moby/v2/integration-cli/daemon"
|
||||
"github.com/moby/moby/v2/testutil"
|
||||
@@ -1025,11 +1026,11 @@ func (s *DockerSwarmSuite) TestAPINetworkInspectWithScope(c *testing.T) {
|
||||
resp, err := apiclient.NetworkCreate(ctx, name, network.CreateOptions{Driver: "overlay"})
|
||||
assert.NilError(c, err)
|
||||
|
||||
nw, err := apiclient.NetworkInspect(ctx, name, network.InspectOptions{})
|
||||
nw, err := apiclient.NetworkInspect(ctx, name, client.InspectOptions{})
|
||||
assert.NilError(c, err)
|
||||
assert.Check(c, is.Equal("swarm", nw.Scope))
|
||||
assert.Check(c, is.Equal(resp.ID, nw.ID))
|
||||
|
||||
_, err = apiclient.NetworkInspect(ctx, name, network.InspectOptions{Scope: "local"})
|
||||
_, err = apiclient.NetworkInspect(ctx, name, client.InspectOptions{Scope: "local"})
|
||||
assert.Check(c, is.ErrorType(err, cerrdefs.IsNotFound))
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"time"
|
||||
|
||||
containertypes "github.com/moby/moby/api/types/container"
|
||||
"github.com/moby/moby/api/types/network"
|
||||
"github.com/moby/moby/client"
|
||||
realcontainer "github.com/moby/moby/v2/daemon/container"
|
||||
"github.com/moby/moby/v2/integration/internal/container"
|
||||
"github.com/moby/moby/v2/testutil"
|
||||
@@ -153,7 +153,7 @@ func TestDaemonHostGatewayIP(t *testing.T) {
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, is.Len(res.Stderr(), 0))
|
||||
assert.Equal(t, 0, res.ExitCode)
|
||||
inspect, err := c.NetworkInspect(ctx, "bridge", network.InspectOptions{})
|
||||
inspect, err := c.NetworkInspect(ctx, "bridge", client.InspectOptions{})
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Contains(res.Stdout(), inspect.IPAM.Config[0].Gateway))
|
||||
c.ContainerRemove(ctx, cID, containertypes.RemoveOptions{Force: true})
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"github.com/moby/moby/api/types/network"
|
||||
swarmtypes "github.com/moby/moby/api/types/swarm"
|
||||
"github.com/moby/moby/client"
|
||||
"github.com/moby/moby/v2/daemon/libnetwork/nlwrap"
|
||||
"github.com/moby/moby/v2/integration/internal/testutils/networking"
|
||||
"github.com/moby/moby/v2/testutil"
|
||||
@@ -418,7 +419,7 @@ func testDefaultBridgeIPAM(ctx context.Context, t *testing.T, tc defaultBridgeIP
|
||||
c := d.NewClientT(t)
|
||||
defer c.Close()
|
||||
|
||||
insp, err := c.NetworkInspect(ctx, network.NetworkBridge, network.InspectOptions{})
|
||||
insp, err := c.NetworkInspect(ctx, network.NetworkBridge, client.InspectOptions{})
|
||||
assert.NilError(t, err)
|
||||
expIPAMConfig := slices.Clone(tc.expIPAMConfig)
|
||||
for i := range expIPAMConfig {
|
||||
|
||||
@@ -3,15 +3,14 @@ package network
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/moby/moby/api/types/network"
|
||||
"github.com/moby/moby/client"
|
||||
"gotest.tools/v3/poll"
|
||||
)
|
||||
|
||||
// IsRemoved verifies the network is removed.
|
||||
func IsRemoved(ctx context.Context, client client.NetworkAPIClient, networkID string) func(log poll.LogT) poll.Result {
|
||||
func IsRemoved(ctx context.Context, apiClient client.NetworkAPIClient, networkID string) func(log poll.LogT) poll.Result {
|
||||
return func(log poll.LogT) poll.Result {
|
||||
_, err := client.NetworkInspect(ctx, networkID, network.InspectOptions{})
|
||||
_, err := apiClient.NetworkInspect(ctx, networkID, client.InspectOptions{})
|
||||
if err == nil {
|
||||
return poll.Continue("waiting for network %s to be removed", networkID)
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
containertypes "github.com/moby/moby/api/types/container"
|
||||
networktypes "github.com/moby/moby/api/types/network"
|
||||
"github.com/moby/moby/api/types/versions"
|
||||
"github.com/moby/moby/client"
|
||||
"github.com/moby/moby/v2/daemon/libnetwork/drivers/bridge"
|
||||
"github.com/moby/moby/v2/daemon/libnetwork/netlabel"
|
||||
"github.com/moby/moby/v2/daemon/libnetwork/nlwrap"
|
||||
@@ -64,7 +65,7 @@ func TestCreateWithIPv6DefaultsToULAPrefix(t *testing.T) {
|
||||
network.CreateNoError(ctx, t, apiClient, nwName, network.WithIPv6())
|
||||
defer network.RemoveNoError(ctx, t, apiClient, nwName)
|
||||
|
||||
nw, err := apiClient.NetworkInspect(ctx, "testnetula", networktypes.InspectOptions{})
|
||||
nw, err := apiClient.NetworkInspect(ctx, "testnetula", client.InspectOptions{})
|
||||
assert.NilError(t, err)
|
||||
|
||||
for _, ipam := range nw.IPAM.Config {
|
||||
@@ -91,7 +92,7 @@ func TestCreateWithIPv6WithoutEnableIPv6Flag(t *testing.T) {
|
||||
network.CreateNoError(ctx, t, apiClient, nwName)
|
||||
defer network.RemoveNoError(ctx, t, apiClient, nwName)
|
||||
|
||||
nw, err := apiClient.NetworkInspect(ctx, "testnetula", networktypes.InspectOptions{})
|
||||
nw, err := apiClient.NetworkInspect(ctx, "testnetula", client.InspectOptions{})
|
||||
assert.NilError(t, err)
|
||||
|
||||
for _, ipam := range nw.IPAM.Config {
|
||||
@@ -136,7 +137,7 @@ func TestDefaultIPvOptOverride(t *testing.T) {
|
||||
network.CreateNoError(ctx, t, c, netName, nopts...)
|
||||
defer network.RemoveNoError(ctx, t, c, netName)
|
||||
|
||||
insp, err := c.NetworkInspect(ctx, netName, networktypes.InspectOptions{})
|
||||
insp, err := c.NetworkInspect(ctx, netName, client.InspectOptions{})
|
||||
assert.NilError(t, err)
|
||||
t.Log("override4", override4, "override6", override6, "->", insp.Options)
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package network
|
||||
import (
|
||||
"testing"
|
||||
|
||||
networktypes "github.com/moby/moby/api/types/network"
|
||||
"github.com/moby/moby/client"
|
||||
"github.com/moby/moby/v2/integration/internal/network"
|
||||
"github.com/moby/moby/v2/integration/internal/swarm"
|
||||
"github.com/moby/moby/v2/testutil"
|
||||
@@ -41,33 +41,33 @@ func TestInspectNetwork(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
network string
|
||||
opts networktypes.InspectOptions
|
||||
opts client.InspectOptions
|
||||
}{
|
||||
{
|
||||
name: "full network id",
|
||||
network: overlayID,
|
||||
opts: networktypes.InspectOptions{
|
||||
opts: client.InspectOptions{
|
||||
Verbose: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "partial network id",
|
||||
network: overlayID[0:11],
|
||||
opts: networktypes.InspectOptions{
|
||||
opts: client.InspectOptions{
|
||||
Verbose: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "network name",
|
||||
network: networkName,
|
||||
opts: networktypes.InspectOptions{
|
||||
opts: client.InspectOptions{
|
||||
Verbose: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "network name and swarm scope",
|
||||
network: networkName,
|
||||
opts: networktypes.InspectOptions{
|
||||
opts: client.InspectOptions{
|
||||
Verbose: true,
|
||||
Scope: "swarm",
|
||||
},
|
||||
|
||||
@@ -89,7 +89,7 @@ func TestHostIPv4BridgeLabel(t *testing.T) {
|
||||
network.WithOption("com.docker.network.bridge.name", bridgeName),
|
||||
)
|
||||
defer network.RemoveNoError(ctx, t, c, bridgeName)
|
||||
out, err := c.NetworkInspect(ctx, bridgeName, networktypes.InspectOptions{Verbose: true})
|
||||
out, err := c.NetworkInspect(ctx, bridgeName, client.InspectOptions{Verbose: true})
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, len(out.IPAM.Config) > 0)
|
||||
// Make sure the SNAT rule exists
|
||||
|
||||
@@ -45,7 +45,7 @@ func TestDaemonRestartWithLiveRestore(t *testing.T) {
|
||||
defer c.Close()
|
||||
|
||||
// Verify bridge network's subnet
|
||||
out, err := c.NetworkInspect(ctx, "bridge", networktypes.InspectOptions{})
|
||||
out, err := c.NetworkInspect(ctx, "bridge", client.InspectOptions{})
|
||||
assert.NilError(t, err)
|
||||
subnet := out.IPAM.Config[0].Subnet
|
||||
|
||||
@@ -55,7 +55,7 @@ func TestDaemonRestartWithLiveRestore(t *testing.T) {
|
||||
"--default-address-pool", "base=175.33.0.0/16,size=24",
|
||||
)
|
||||
|
||||
out1, err := c.NetworkInspect(ctx, "bridge", networktypes.InspectOptions{})
|
||||
out1, err := c.NetworkInspect(ctx, "bridge", client.InspectOptions{})
|
||||
assert.NilError(t, err)
|
||||
// Make sure docker0 doesn't get override with new IP in live restore case
|
||||
assert.Equal(t, out1.IPAM.Config[0].Subnet, subnet)
|
||||
@@ -82,7 +82,7 @@ func TestDaemonDefaultNetworkPools(t *testing.T) {
|
||||
defer c.Close()
|
||||
|
||||
// Verify bridge network's subnet
|
||||
out, err := c.NetworkInspect(ctx, "bridge", networktypes.InspectOptions{})
|
||||
out, err := c.NetworkInspect(ctx, "bridge", client.InspectOptions{})
|
||||
assert.NilError(t, err)
|
||||
assert.Equal(t, out.IPAM.Config[0].Subnet, "175.30.0.0/16")
|
||||
|
||||
@@ -92,7 +92,7 @@ func TestDaemonDefaultNetworkPools(t *testing.T) {
|
||||
network.WithDriver("bridge"),
|
||||
)
|
||||
defer network.RemoveNoError(ctx, t, c, name)
|
||||
out, err = c.NetworkInspect(ctx, name, networktypes.InspectOptions{})
|
||||
out, err = c.NetworkInspect(ctx, name, client.InspectOptions{})
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal(out.IPAM.Config[0].Subnet, "175.33.0.0/24"))
|
||||
|
||||
@@ -102,7 +102,7 @@ func TestDaemonDefaultNetworkPools(t *testing.T) {
|
||||
network.WithDriver("bridge"),
|
||||
)
|
||||
defer network.RemoveNoError(ctx, t, c, name)
|
||||
out, err = c.NetworkInspect(ctx, name, networktypes.InspectOptions{})
|
||||
out, err = c.NetworkInspect(ctx, name, client.InspectOptions{})
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal(out.IPAM.Config[0].Subnet, "175.33.1.0/24"))
|
||||
}
|
||||
@@ -127,7 +127,7 @@ func TestDaemonRestartWithExistingNetwork(t *testing.T) {
|
||||
defer network.RemoveNoError(ctx, t, c, name)
|
||||
|
||||
// Verify bridge network's subnet
|
||||
out, err := c.NetworkInspect(ctx, name, networktypes.InspectOptions{})
|
||||
out, err := c.NetworkInspect(ctx, name, client.InspectOptions{})
|
||||
assert.NilError(t, err)
|
||||
networkip := out.IPAM.Config[0].Subnet
|
||||
|
||||
@@ -137,7 +137,7 @@ func TestDaemonRestartWithExistingNetwork(t *testing.T) {
|
||||
"--default-address-pool", "base=175.33.0.0/16,size=24")
|
||||
defer delInterface(ctx, t, "docker0")
|
||||
|
||||
out1, err := c.NetworkInspect(ctx, name, networktypes.InspectOptions{})
|
||||
out1, err := c.NetworkInspect(ctx, name, client.InspectOptions{})
|
||||
assert.NilError(t, err)
|
||||
assert.Equal(t, out1.IPAM.Config[0].Subnet, networkip)
|
||||
}
|
||||
@@ -163,7 +163,7 @@ func TestDaemonRestartWithExistingNetworkWithDefaultPoolRange(t *testing.T) {
|
||||
defer network.RemoveNoError(ctx, t, c, name)
|
||||
|
||||
// Verify bridge network's subnet
|
||||
out, err := c.NetworkInspect(ctx, name, networktypes.InspectOptions{})
|
||||
out, err := c.NetworkInspect(ctx, name, client.InspectOptions{})
|
||||
assert.NilError(t, err)
|
||||
networkip := out.IPAM.Config[0].Subnet
|
||||
|
||||
@@ -173,7 +173,7 @@ func TestDaemonRestartWithExistingNetworkWithDefaultPoolRange(t *testing.T) {
|
||||
network.WithDriver("bridge"),
|
||||
)
|
||||
defer network.RemoveNoError(ctx, t, c, name)
|
||||
out, err = c.NetworkInspect(ctx, name, networktypes.InspectOptions{})
|
||||
out, err = c.NetworkInspect(ctx, name, client.InspectOptions{})
|
||||
assert.NilError(t, err)
|
||||
networkip2 := out.IPAM.Config[0].Subnet
|
||||
|
||||
@@ -190,7 +190,7 @@ func TestDaemonRestartWithExistingNetworkWithDefaultPoolRange(t *testing.T) {
|
||||
network.WithDriver("bridge"),
|
||||
)
|
||||
defer network.RemoveNoError(ctx, t, c, name)
|
||||
out1, err := c.NetworkInspect(ctx, name, networktypes.InspectOptions{})
|
||||
out1, err := c.NetworkInspect(ctx, name, client.InspectOptions{})
|
||||
assert.NilError(t, err)
|
||||
|
||||
assert.Check(t, out1.IPAM.Config[0].Subnet != networkip)
|
||||
@@ -217,7 +217,7 @@ func TestDaemonWithBipAndDefaultNetworkPool(t *testing.T) {
|
||||
defer c.Close()
|
||||
|
||||
// Verify bridge network's subnet
|
||||
out, err := c.NetworkInspect(ctx, "bridge", networktypes.InspectOptions{})
|
||||
out, err := c.NetworkInspect(ctx, "bridge", client.InspectOptions{})
|
||||
assert.NilError(t, err)
|
||||
// Make sure BIP IP doesn't get override with new default address pool .
|
||||
assert.Equal(t, out.IPAM.Config[0].Subnet, "172.60.0.0/16")
|
||||
@@ -297,7 +297,7 @@ func TestServiceRemoveKeepsIngressNetwork(t *testing.T) {
|
||||
|
||||
// Ensure that "ingress" is not removed or corrupted
|
||||
time.Sleep(10 * time.Second)
|
||||
netInfo, err := c.NetworkInspect(ctx, ingressNet, networktypes.InspectOptions{
|
||||
netInfo, err := c.NetworkInspect(ctx, ingressNet, client.InspectOptions{
|
||||
Verbose: true,
|
||||
Scope: "swarm",
|
||||
})
|
||||
@@ -309,9 +309,9 @@ func TestServiceRemoveKeepsIngressNetwork(t *testing.T) {
|
||||
}
|
||||
|
||||
//nolint:unused // for some reason, the "unused" linter marks this function as "unused"
|
||||
func swarmIngressReady(ctx context.Context, client client.NetworkAPIClient) func(log poll.LogT) poll.Result {
|
||||
func swarmIngressReady(ctx context.Context, apiClient client.NetworkAPIClient) func(log poll.LogT) poll.Result {
|
||||
return func(log poll.LogT) poll.Result {
|
||||
netInfo, err := client.NetworkInspect(ctx, ingressNet, networktypes.InspectOptions{
|
||||
netInfo, err := apiClient.NetworkInspect(ctx, ingressNet, client.InspectOptions{
|
||||
Verbose: true,
|
||||
Scope: "swarm",
|
||||
})
|
||||
@@ -443,7 +443,7 @@ func TestServiceWithDefaultAddressPoolInit(t *testing.T) {
|
||||
_, _, err := cli.ServiceInspectWithRaw(ctx, serviceID, swarmtypes.ServiceInspectOptions{})
|
||||
assert.NilError(t, err)
|
||||
|
||||
out, err := cli.NetworkInspect(ctx, overlayID, networktypes.InspectOptions{Verbose: true})
|
||||
out, err := cli.NetworkInspect(ctx, overlayID, client.InspectOptions{Verbose: true})
|
||||
assert.NilError(t, err)
|
||||
t.Logf("%s: NetworkInspect: %+v", t.Name(), out)
|
||||
assert.Assert(t, len(out.IPAM.Config) > 0)
|
||||
@@ -454,7 +454,7 @@ func TestServiceWithDefaultAddressPoolInit(t *testing.T) {
|
||||
assert.Equal(t, out.IPAM.Config[0].Subnet, "20.20.1.0/24")
|
||||
|
||||
// Also inspect ingress network and make sure its in the same subnet
|
||||
out, err = cli.NetworkInspect(ctx, "ingress", networktypes.InspectOptions{Verbose: true})
|
||||
out, err = cli.NetworkInspect(ctx, "ingress", client.InspectOptions{Verbose: true})
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, len(out.IPAM.Config) > 0)
|
||||
assert.Equal(t, out.IPAM.Config[0].Subnet, "20.20.0.0/24")
|
||||
|
||||
@@ -584,7 +584,7 @@ func TestAccessToPublishedPort(t *testing.T) {
|
||||
// Use the default bridge addresses as host addresses (like "host-gateway", but
|
||||
// there's no way to tell wget to prefer ipv4/ipv6 transport, so just use the
|
||||
// addresses directly).
|
||||
insp, err := c.NetworkInspect(ctx, "bridge", networktypes.InspectOptions{})
|
||||
insp, err := c.NetworkInspect(ctx, "bridge", client.InspectOptions{})
|
||||
assert.NilError(t, err)
|
||||
for _, ipamCfg := range insp.IPAM.Config {
|
||||
ipv := "ipv4"
|
||||
@@ -1821,7 +1821,7 @@ func TestNetworkInspectGateway(t *testing.T) {
|
||||
assert.NilError(t, err)
|
||||
defer network.RemoveNoError(ctx, t, c, netName)
|
||||
|
||||
insp, err := c.NetworkInspect(ctx, nid, networktypes.InspectOptions{})
|
||||
insp, err := c.NetworkInspect(ctx, nid, client.InspectOptions{})
|
||||
assert.NilError(t, err)
|
||||
for _, ipamCfg := range insp.IPAM.Config {
|
||||
_, err := netip.ParseAddr(ipamCfg.Gateway)
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
|
||||
"github.com/moby/moby/api/types/container"
|
||||
"github.com/moby/moby/api/types/filters"
|
||||
networktypes "github.com/moby/moby/api/types/network"
|
||||
swarmtypes "github.com/moby/moby/api/types/swarm"
|
||||
"github.com/moby/moby/client"
|
||||
"github.com/moby/moby/v2/integration/internal/network"
|
||||
@@ -222,7 +221,7 @@ func TestServiceUpdateNetwork(t *testing.T) {
|
||||
|
||||
poll.WaitOn(t, swarm.RunningTasksCount(ctx, cli, serviceID, instances), swarm.ServicePoll)
|
||||
service := getService(ctx, t, cli, serviceID)
|
||||
netInfo, err := cli.NetworkInspect(ctx, testNet, networktypes.InspectOptions{
|
||||
netInfo, err := cli.NetworkInspect(ctx, testNet, client.InspectOptions{
|
||||
Verbose: true,
|
||||
Scope: "swarm",
|
||||
})
|
||||
@@ -235,7 +234,7 @@ func TestServiceUpdateNetwork(t *testing.T) {
|
||||
assert.NilError(t, err)
|
||||
poll.WaitOn(t, serviceIsUpdated(ctx, cli, serviceID), swarm.ServicePoll)
|
||||
|
||||
netInfo, err = cli.NetworkInspect(ctx, testNet, networktypes.InspectOptions{
|
||||
netInfo, err = cli.NetworkInspect(ctx, testNet, client.InspectOptions{
|
||||
Verbose: true,
|
||||
Scope: "swarm",
|
||||
})
|
||||
|
||||
6
vendor/github.com/moby/moby/api/types/network/network.go
generated
vendored
6
vendor/github.com/moby/moby/api/types/network/network.go
generated
vendored
@@ -45,12 +45,6 @@ type CreateOptions struct {
|
||||
Labels map[string]string // Labels holds metadata specific to the network being created.
|
||||
}
|
||||
|
||||
// InspectOptions holds parameters to inspect network.
|
||||
type InspectOptions struct {
|
||||
Scope string
|
||||
Verbose bool
|
||||
}
|
||||
|
||||
// ConnectOptions represents the data to be used to connect a container to the
|
||||
// network.
|
||||
type ConnectOptions struct {
|
||||
|
||||
4
vendor/github.com/moby/moby/client/client_interfaces.go
generated
vendored
4
vendor/github.com/moby/moby/client/client_interfaces.go
generated
vendored
@@ -131,8 +131,8 @@ type NetworkAPIClient interface {
|
||||
NetworkConnect(ctx context.Context, network, container string, config *network.EndpointSettings) error
|
||||
NetworkCreate(ctx context.Context, name string, options network.CreateOptions) (network.CreateResponse, error)
|
||||
NetworkDisconnect(ctx context.Context, network, container string, force bool) error
|
||||
NetworkInspect(ctx context.Context, network string, options network.InspectOptions) (network.Inspect, error)
|
||||
NetworkInspectWithRaw(ctx context.Context, network string, options network.InspectOptions) (network.Inspect, []byte, error)
|
||||
NetworkInspect(ctx context.Context, network string, options InspectOptions) (network.Inspect, error)
|
||||
NetworkInspectWithRaw(ctx context.Context, network string, options InspectOptions) (network.Inspect, []byte, error)
|
||||
NetworkList(ctx context.Context, options NetworkListOptions) ([]network.Summary, error)
|
||||
NetworkRemove(ctx context.Context, network string) error
|
||||
NetworksPrune(ctx context.Context, pruneFilter filters.Args) (network.PruneReport, error)
|
||||
|
||||
4
vendor/github.com/moby/moby/client/network_inspect.go
generated
vendored
4
vendor/github.com/moby/moby/client/network_inspect.go
generated
vendored
@@ -11,13 +11,13 @@ import (
|
||||
)
|
||||
|
||||
// NetworkInspect returns the information for a specific network configured in the docker host.
|
||||
func (cli *Client) NetworkInspect(ctx context.Context, networkID string, options network.InspectOptions) (network.Inspect, error) {
|
||||
func (cli *Client) NetworkInspect(ctx context.Context, networkID string, options InspectOptions) (network.Inspect, error) {
|
||||
networkResource, _, err := cli.NetworkInspectWithRaw(ctx, networkID, options)
|
||||
return networkResource, err
|
||||
}
|
||||
|
||||
// NetworkInspectWithRaw returns the information for a specific network configured in the docker host and its raw representation.
|
||||
func (cli *Client) NetworkInspectWithRaw(ctx context.Context, networkID string, options network.InspectOptions) (network.Inspect, []byte, error) {
|
||||
func (cli *Client) NetworkInspectWithRaw(ctx context.Context, networkID string, options InspectOptions) (network.Inspect, []byte, error) {
|
||||
networkID, err := trimID("network", networkID)
|
||||
if err != nil {
|
||||
return network.Inspect{}, nil, err
|
||||
|
||||
7
vendor/github.com/moby/moby/client/network_inspect_opts.go
generated
vendored
Normal file
7
vendor/github.com/moby/moby/client/network_inspect_opts.go
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
package client
|
||||
|
||||
// InspectOptions holds parameters to inspect network.
|
||||
type InspectOptions struct {
|
||||
Scope string
|
||||
Verbose bool
|
||||
}
|
||||
Reference in New Issue
Block a user