diff --git a/api/types/network/network.go b/api/types/network/network.go index f9a206f189..f07a938204 100644 --- a/api/types/network/network.go +++ b/api/types/network/network.go @@ -45,11 +45,6 @@ type CreateOptions struct { Labels map[string]string // Labels holds metadata specific to the network being created. } -// ListOptions holds parameters to filter the list of networks with. -type ListOptions struct { - Filters filters.Args -} - // InspectOptions holds parameters to inspect network. type InspectOptions struct { Scope string diff --git a/client/client_interfaces.go b/client/client_interfaces.go index be406114e6..5c83e15511 100644 --- a/client/client_interfaces.go +++ b/client/client_interfaces.go @@ -133,7 +133,7 @@ type NetworkAPIClient interface { 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) - NetworkList(ctx context.Context, options network.ListOptions) ([]network.Summary, error) + NetworkList(ctx context.Context, options ListOptions) ([]network.Summary, error) NetworkRemove(ctx context.Context, network string) error NetworksPrune(ctx context.Context, pruneFilter filters.Args) (network.PruneReport, error) } diff --git a/client/network_list.go b/client/network_list.go index 5069c3bfe4..9a51c6a0c4 100644 --- a/client/network_list.go +++ b/client/network_list.go @@ -11,7 +11,7 @@ import ( ) // NetworkList returns the list of networks configured in the docker host. -func (cli *Client) NetworkList(ctx context.Context, options network.ListOptions) ([]network.Summary, error) { +func (cli *Client) NetworkList(ctx context.Context, options ListOptions) ([]network.Summary, error) { query := url.Values{} if options.Filters.Len() > 0 { filterJSON, err := filters.ToJSON(options.Filters) diff --git a/client/network_list_opts.go b/client/network_list_opts.go new file mode 100644 index 0000000000..4b3edf9a90 --- /dev/null +++ b/client/network_list_opts.go @@ -0,0 +1,8 @@ +package client + +import "github.com/moby/moby/api/types/filters" + +// ListOptions holds parameters to filter the list of networks with. +type ListOptions struct { + Filters filters.Args +} diff --git a/client/network_list_test.go b/client/network_list_test.go index 12f502f661..36112162fa 100644 --- a/client/network_list_test.go +++ b/client/network_list_test.go @@ -22,7 +22,7 @@ func TestNetworkListError(t *testing.T) { client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), } - _, err := client.NetworkList(context.Background(), network.ListOptions{}) + _, err := client.NetworkList(context.Background(), ListOptions{}) assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal)) } @@ -30,27 +30,27 @@ func TestNetworkList(t *testing.T) { const expectedURL = "/networks" listCases := []struct { - options network.ListOptions + options ListOptions expectedFilters string }{ { - options: network.ListOptions{}, + options: ListOptions{}, expectedFilters: "", }, { - options: network.ListOptions{ + options: ListOptions{ Filters: filters.NewArgs(filters.Arg("dangling", "false")), }, expectedFilters: `{"dangling":{"false":true}}`, }, { - options: network.ListOptions{ + options: ListOptions{ Filters: filters.NewArgs(filters.Arg("dangling", "true")), }, expectedFilters: `{"dangling":{"true":true}}`, }, { - options: network.ListOptions{ + options: ListOptions{ Filters: filters.NewArgs( filters.Arg("label", "label1"), filters.Arg("label", "label2"), diff --git a/integration-cli/requirements_test.go b/integration-cli/requirements_test.go index f97a3c791e..931a525805 100644 --- a/integration-cli/requirements_test.go +++ b/integration-cli/requirements_test.go @@ -16,7 +16,6 @@ import ( "time" "github.com/containerd/containerd/v2/plugins" - "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/cli" @@ -36,7 +35,7 @@ func OnlyDefaultNetworks(ctx context.Context) bool { if err != nil { return false } - networks, err := apiClient.NetworkList(ctx, network.ListOptions{}) + networks, err := apiClient.NetworkList(ctx, client.ListOptions{}) if err != nil || len(networks) > 0 { return false } diff --git a/integration/network/delete_test.go b/integration/network/delete_test.go index 0831b2c195..82fe263d1d 100644 --- a/integration/network/delete_test.go +++ b/integration/network/delete_test.go @@ -31,7 +31,7 @@ func createAmbiguousNetworks(ctx context.Context, t *testing.T, apiClient client idPrefixNet := network.CreateNoError(ctx, t, apiClient, testNet[:12]) fullIDNet := network.CreateNoError(ctx, t, apiClient, testNet) - nws, err := apiClient.NetworkList(ctx, networktypes.ListOptions{}) + nws, err := apiClient.NetworkList(ctx, client.ListOptions{}) assert.NilError(t, err) assert.Check(t, is.Equal(true, containsNetwork(nws, testNet)), "failed to create network testNet") @@ -79,7 +79,7 @@ func TestDockerNetworkDeletePreferID(t *testing.T) { assert.NilError(t, err) // networks "testNet" and "idPrefixNet" should be removed, but "fullIDNet" should still exist - nws, err := apiClient.NetworkList(ctx, networktypes.ListOptions{}) + nws, err := apiClient.NetworkList(ctx, client.ListOptions{}) assert.NilError(t, err) assert.Check(t, is.Equal(false, containsNetwork(nws, testNet)), "Network testNet not removed") assert.Check(t, is.Equal(false, containsNetwork(nws, idPrefixNet)), "Network idPrefixNet not removed") diff --git a/integration/network/helpers.go b/integration/network/helpers.go index d35ed1d997..5107ef0474 100644 --- a/integration/network/helpers.go +++ b/integration/network/helpers.go @@ -7,7 +7,6 @@ import ( "fmt" "testing" - "github.com/moby/moby/api/types/network" "github.com/moby/moby/client" "github.com/moby/moby/v2/testutil" is "gotest.tools/v3/assert/cmp" @@ -54,7 +53,7 @@ func LinkDoesntExist(ctx context.Context, t *testing.T, master string) { // IsNetworkAvailable provides a comparison to check if a docker network is available func IsNetworkAvailable(ctx context.Context, c client.NetworkAPIClient, name string) is.Comparison { return func() is.Result { - networks, err := c.NetworkList(ctx, network.ListOptions{}) + networks, err := c.NetworkList(ctx, client.ListOptions{}) if err != nil { return is.ResultFromError(err) } @@ -70,7 +69,7 @@ func IsNetworkAvailable(ctx context.Context, c client.NetworkAPIClient, name str // IsNetworkNotAvailable provides a comparison to check if a docker network is not available func IsNetworkNotAvailable(ctx context.Context, c client.NetworkAPIClient, name string) is.Comparison { return func() is.Result { - networks, err := c.NetworkList(ctx, network.ListOptions{}) + networks, err := c.NetworkList(ctx, client.ListOptions{}) if err != nil { return is.ResultFromError(err) } diff --git a/integration/network/helpers_windows.go b/integration/network/helpers_windows.go index b9cb025fb0..30c0f712c8 100644 --- a/integration/network/helpers_windows.go +++ b/integration/network/helpers_windows.go @@ -4,7 +4,6 @@ import ( "context" "fmt" - "github.com/moby/moby/api/types/network" "github.com/moby/moby/client" "gotest.tools/v3/assert/cmp" ) @@ -12,7 +11,7 @@ import ( // IsNetworkAvailable provides a comparison to check if a docker network is available func IsNetworkAvailable(ctx context.Context, c client.NetworkAPIClient, name string) cmp.Comparison { return func() cmp.Result { - networks, err := c.NetworkList(ctx, network.ListOptions{}) + networks, err := c.NetworkList(ctx, client.ListOptions{}) if err != nil { return cmp.ResultFromError(err) } @@ -28,7 +27,7 @@ func IsNetworkAvailable(ctx context.Context, c client.NetworkAPIClient, name str // IsNetworkNotAvailable provides a comparison to check if a docker network is not available func IsNetworkNotAvailable(ctx context.Context, c client.NetworkAPIClient, name string) cmp.Comparison { return func() cmp.Result { - networks, err := c.NetworkList(ctx, network.ListOptions{}) + networks, err := c.NetworkList(ctx, client.ListOptions{}) if err != nil { return cmp.ResultFromError(err) } diff --git a/testutil/environment/clean.go b/testutil/environment/clean.go index 03df56403d..8b305124a7 100644 --- a/testutil/environment/clean.go +++ b/testutil/environment/clean.go @@ -143,7 +143,7 @@ func deleteAllVolumes(ctx context.Context, t testing.TB, c client.VolumeAPIClien func deleteAllNetworks(ctx context.Context, t testing.TB, c client.NetworkAPIClient, daemonPlatform string, protectedNetworks map[string]struct{}) { t.Helper() - networks, err := c.NetworkList(ctx, network.ListOptions{}) + networks, err := c.NetworkList(ctx, client.ListOptions{}) assert.Check(t, err, "failed to list networks") for _, n := range networks { diff --git a/testutil/environment/protect.go b/testutil/environment/protect.go index 6c2a1004c2..1221697076 100644 --- a/testutil/environment/protect.go +++ b/testutil/environment/protect.go @@ -8,7 +8,6 @@ import ( "github.com/moby/moby/api/types/container" "github.com/moby/moby/api/types/filters" "github.com/moby/moby/api/types/image" - "github.com/moby/moby/api/types/network" "github.com/moby/moby/client" "github.com/moby/moby/v2/testutil" "go.opentelemetry.io/otel" @@ -168,8 +167,8 @@ func ProtectNetworks(ctx context.Context, t testing.TB, testEnv *Execution) { func getExistingNetworks(ctx context.Context, t testing.TB, testEnv *Execution) []string { t.Helper() - client := testEnv.APIClient() - networkList, err := client.NetworkList(ctx, network.ListOptions{}) + apiClient := testEnv.APIClient() + networkList, err := apiClient.NetworkList(ctx, client.ListOptions{}) assert.NilError(t, err, "failed to list networks") var networks []string diff --git a/vendor/github.com/moby/moby/api/types/network/network.go b/vendor/github.com/moby/moby/api/types/network/network.go index f9a206f189..f07a938204 100644 --- a/vendor/github.com/moby/moby/api/types/network/network.go +++ b/vendor/github.com/moby/moby/api/types/network/network.go @@ -45,11 +45,6 @@ type CreateOptions struct { Labels map[string]string // Labels holds metadata specific to the network being created. } -// ListOptions holds parameters to filter the list of networks with. -type ListOptions struct { - Filters filters.Args -} - // InspectOptions holds parameters to inspect network. type InspectOptions struct { Scope string diff --git a/vendor/github.com/moby/moby/client/client_interfaces.go b/vendor/github.com/moby/moby/client/client_interfaces.go index be406114e6..5c83e15511 100644 --- a/vendor/github.com/moby/moby/client/client_interfaces.go +++ b/vendor/github.com/moby/moby/client/client_interfaces.go @@ -133,7 +133,7 @@ type NetworkAPIClient interface { 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) - NetworkList(ctx context.Context, options network.ListOptions) ([]network.Summary, error) + NetworkList(ctx context.Context, options ListOptions) ([]network.Summary, error) NetworkRemove(ctx context.Context, network string) error NetworksPrune(ctx context.Context, pruneFilter filters.Args) (network.PruneReport, error) } diff --git a/vendor/github.com/moby/moby/client/network_list.go b/vendor/github.com/moby/moby/client/network_list.go index 5069c3bfe4..9a51c6a0c4 100644 --- a/vendor/github.com/moby/moby/client/network_list.go +++ b/vendor/github.com/moby/moby/client/network_list.go @@ -11,7 +11,7 @@ import ( ) // NetworkList returns the list of networks configured in the docker host. -func (cli *Client) NetworkList(ctx context.Context, options network.ListOptions) ([]network.Summary, error) { +func (cli *Client) NetworkList(ctx context.Context, options ListOptions) ([]network.Summary, error) { query := url.Values{} if options.Filters.Len() > 0 { filterJSON, err := filters.ToJSON(options.Filters) diff --git a/vendor/github.com/moby/moby/client/network_list_opts.go b/vendor/github.com/moby/moby/client/network_list_opts.go new file mode 100644 index 0000000000..4b3edf9a90 --- /dev/null +++ b/vendor/github.com/moby/moby/client/network_list_opts.go @@ -0,0 +1,8 @@ +package client + +import "github.com/moby/moby/api/types/filters" + +// ListOptions holds parameters to filter the list of networks with. +type ListOptions struct { + Filters filters.Args +}