mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
abf31ee083
This fix is partially based on comment https://github.com/docker/docker/issues/30242#issuecomment-273517205 Currently, `docker network inspect` relies on `FindNetwork()` which does not take into consideration that multiple networks with the same name might exist. This fix propose to return `docker network inspect` in a similiar fashion like other commands: 1. Lookup full ID 2. Lookup full name 3. Lookup partial ID If multiple networks exist, an error will be returned. NOTE: this fix is not a complete fix for the issue raised in https://github.com/docker/docker/issues/30242#issuecomment-273517205 where SwarmKit is unable to update when multiple networks with the same name exit. To fix that issue requires multiple places when `FindNetwork()` is called. Because of the impact of changing `FindNetwork()`, this fix focus on the issue in `docker network inspect`. A separate PR will be created to address https://github.com/docker/docker/issues/30242#issuecomment-273517205 An integration test has been added. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
20 lines
812 B
Go
20 lines
812 B
Go
package network
|
|
|
|
import (
|
|
"github.com/docker/docker/api/types"
|
|
"github.com/docker/docker/api/types/filters"
|
|
"github.com/docker/docker/api/types/network"
|
|
"github.com/docker/libnetwork"
|
|
)
|
|
|
|
// Backend is all the methods that need to be implemented
|
|
// to provide network specific functionality.
|
|
type Backend interface {
|
|
FindNetwork(idName string) (libnetwork.Network, error)
|
|
GetNetworks() []libnetwork.Network
|
|
CreateNetwork(nc types.NetworkCreateRequest) (*types.NetworkCreateResponse, error)
|
|
ConnectContainerToNetwork(containerName, networkName string, endpointConfig *network.EndpointSettings) error
|
|
DisconnectContainerFromNetwork(containerName string, networkName string, force bool) error
|
|
DeleteNetwork(name string) error
|
|
NetworksPrune(pruneFilters filters.Args) (*types.NetworksPruneReport, error)
|
|
}
|