diff options
author | Paul Holzinger <paul.holzinger@web.de> | 2020-12-01 22:12:16 +0100 |
---|---|---|
committer | Paul Holzinger <paul.holzinger@web.de> | 2020-12-02 10:27:00 +0100 |
commit | c31a5c0d9c9db52f03caa443a3fdfdce194046e8 (patch) | |
tree | fe21af9d8e5b87e6fa4054bb8d30ce17ab673662 /libpod/network/netconflist.go | |
parent | 9c5fe954cca8b4bcb8f552645e1f52a5d9824134 (diff) | |
download | podman-c31a5c0d9c9db52f03caa443a3fdfdce194046e8.tar.gz podman-c31a5c0d9c9db52f03caa443a3fdfdce194046e8.tar.bz2 podman-c31a5c0d9c9db52f03caa443a3fdfdce194046e8.zip |
Add support for network ids
The network ID is not stored. It is just the sha256 hash from
the network name. There is a risk of a potential hash collision.
However it's very unlikely and even if we hit this it will
complain that more than network with this ID exists.
The main benefit is that the compat api can have proper
network ID support. Also this adds the support for
`podman network ls --format "{{.ID}}"` and `--filter id=<ID>`.
It also ensures that we can do network rm <ID> and network
inspect <ID>.
Since we use a hash this commit is backwards compatible even for
already existing networks.
Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
Diffstat (limited to 'libpod/network/netconflist.go')
-rw-r--r-- | libpod/network/netconflist.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/libpod/network/netconflist.go b/libpod/network/netconflist.go index a5fec5e80..d61b96ecb 100644 --- a/libpod/network/netconflist.go +++ b/libpod/network/netconflist.go @@ -230,8 +230,16 @@ func IfPassesFilter(netconf *libcni.NetworkConfigList, filters map[string][]stri } } + case "id": + // matches part of one id + for _, filterValue := range filterValues { + if strings.Contains(GetNetworkID(netconf.Name), filterValue) { + result = true + break + } + } + // TODO: add dangling filter - // TODO TODO: add id filter if we support ids default: return false, errors.Errorf("invalid filter %q", key) |