forked from containers/podman
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The `libpod/network` package should only be used on the backend and not the client. The client used this package only for two functions so move them into a new `pkg/network` package. This is needed so we can put linux only code into `libpod/network`, see containers#9710. [NO TESTS NEEDED] Signed-off-by: Paul Holzinger <[email protected]>
- Loading branch information
Paul Holzinger
committed
Mar 15, 2021
1 parent
fc02d16
commit 762148d
Showing
11 changed files
with
63 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// +build linux | ||
|
||
package libpod | ||
|
||
import ( | ||
"github.com/containers/common/pkg/config" | ||
"github.com/containers/podman/v3/libpod/network" | ||
) | ||
|
||
func normalizeNetworkName(config *config.Config, nameOrID string) (string, error) { | ||
return network.NormalizeName(config, nameOrID) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// +build !linux | ||
|
||
package libpod | ||
|
||
import ( | ||
"github.com/containers/common/pkg/config" | ||
"github.com/containers/podman/v3/libpod/define" | ||
) | ||
|
||
func normalizeNetworkName(config *config.Config, nameOrID string) (string, error) { | ||
return "", define.ErrNotImplemented | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package network | ||
|
||
import ( | ||
"crypto/sha256" | ||
"encoding/hex" | ||
"strings" | ||
|
||
"github.com/containernetworking/cni/libcni" | ||
) | ||
|
||
// GetCNIPlugins returns a list of plugins that a given network | ||
// has in the form of a string | ||
func GetCNIPlugins(list *libcni.NetworkConfigList) string { | ||
plugins := make([]string, 0, len(list.Plugins)) | ||
for _, plug := range list.Plugins { | ||
plugins = append(plugins, plug.Network.Type) | ||
} | ||
return strings.Join(plugins, ",") | ||
} | ||
|
||
// GetNetworkID return the network ID for a given name. | ||
// It is just the sha256 hash but this should be good enough. | ||
// The caller has to make sure it is only called with the network name. | ||
func GetNetworkID(name string) string { | ||
hash := sha256.Sum256([]byte(name)) | ||
return hex.EncodeToString(hash[:]) | ||
} |