mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
Merge pull request #51245 from thaJeztah/network_opts
client: NetworkInspect, NetworkList: wrap output structs, and remove NetworkInspectWithRaw
This commit is contained in:
@@ -144,22 +144,22 @@ 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, client.NetworkListOptions{})
|
||||
res, err := c.NetworkList(ctx, client.NetworkListOptions{})
|
||||
assert.Check(t, err, "failed to list networks")
|
||||
|
||||
for _, n := range networks {
|
||||
if n.Name == network.NetworkBridge || n.Name == network.NetworkNone || n.Name == network.NetworkHost {
|
||||
for _, nw := range res.Items {
|
||||
if nw.Name == network.NetworkBridge || nw.Name == network.NetworkNone || nw.Name == network.NetworkHost {
|
||||
continue
|
||||
}
|
||||
if _, ok := protectedNetworks[n.ID]; ok {
|
||||
if _, ok := protectedNetworks[nw.ID]; ok {
|
||||
continue
|
||||
}
|
||||
if daemonPlatform == "windows" && strings.ToLower(n.Name) == network.NetworkNat {
|
||||
if daemonPlatform == "windows" && strings.ToLower(nw.Name) == network.NetworkNat {
|
||||
// nat is a pre-defined network on Windows and cannot be removed
|
||||
continue
|
||||
}
|
||||
err := c.NetworkRemove(ctx, n.ID)
|
||||
assert.Check(t, err, "failed to remove network %s", n.ID)
|
||||
err := c.NetworkRemove(ctx, nw.ID)
|
||||
assert.Check(t, err, "failed to remove network %s", nw.ID)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -165,14 +165,14 @@ func ProtectNetworks(ctx context.Context, t testing.TB, testEnv *Execution) {
|
||||
func getExistingNetworks(ctx context.Context, t testing.TB, testEnv *Execution) []string {
|
||||
t.Helper()
|
||||
apiClient := testEnv.APIClient()
|
||||
networkList, err := apiClient.NetworkList(ctx, client.NetworkListOptions{})
|
||||
res, err := apiClient.NetworkList(ctx, client.NetworkListOptions{})
|
||||
assert.NilError(t, err, "failed to list networks")
|
||||
|
||||
var networks []string
|
||||
for _, network := range networkList {
|
||||
networks = append(networks, network.ID)
|
||||
var nwIDs []string
|
||||
for _, nw := range res.Items {
|
||||
nwIDs = append(nwIDs, nw.ID)
|
||||
}
|
||||
return networks
|
||||
return nwIDs
|
||||
}
|
||||
|
||||
// ProtectPlugin adds the specified plugin(s) to be protected in case of clean
|
||||
|
||||
Reference in New Issue
Block a user