diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-12-02 15:27:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-02 15:27:14 +0100 |
commit | 7210b86d9ee5aa38a07829e58038049d224cad61 (patch) | |
tree | 3c040ea73c85ff2797c1950d41adec3d37c78c7a /libpod/network/network.go | |
parent | d28874b2f4bc4f522ed2dc63412e9ddfea011fac (diff) | |
parent | c31a5c0d9c9db52f03caa443a3fdfdce194046e8 (diff) | |
download | podman-7210b86d9ee5aa38a07829e58038049d224cad61.tar.gz podman-7210b86d9ee5aa38a07829e58038049d224cad61.tar.bz2 podman-7210b86d9ee5aa38a07829e58038049d224cad61.zip |
Merge pull request #8549 from Luap99/network-id-support
Add support for network ids
Diffstat (limited to 'libpod/network/network.go')
-rw-r--r-- | libpod/network/network.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/libpod/network/network.go b/libpod/network/network.go index 0febb52f6..89f0b67ac 100644 --- a/libpod/network/network.go +++ b/libpod/network/network.go @@ -1,6 +1,8 @@ package network import ( + "crypto/sha256" + "encoding/hex" "encoding/json" "net" "os" @@ -175,7 +177,7 @@ func RemoveNetwork(config *config.Config, name string) error { return err } defer l.releaseCNILock() - cniPath, err := GetCNIConfigPathByName(config, name) + cniPath, err := GetCNIConfigPathByNameOrID(config, name) if err != nil { return err } @@ -229,3 +231,10 @@ func Exists(config *config.Config, name string) (bool, error) { } return true, nil } + +// GetNetworkID return the network ID for a given name. +// It is just the sha256 hash but this should be good enough. +func GetNetworkID(name string) string { + hash := sha256.Sum256([]byte(name)) + return hex.EncodeToString(hash[:]) +} |