summaryrefslogtreecommitdiff
path: root/libpod/network/internal/util/create.go
diff options
context:
space:
mode:
authorPaul Holzinger <pholzing@redhat.com>2021-12-17 14:46:15 +0100
committerPaul Holzinger <pholzing@redhat.com>2022-01-12 17:07:30 +0100
commit495884b3195de482dc610a2a002db7e053188a32 (patch)
tree2a6f23db066cd52aa366991b0b34d7b919368ddc /libpod/network/internal/util/create.go
parent2cdab5d53923784e72020d70ee9375518f19f9b6 (diff)
downloadpodman-495884b3195de482dc610a2a002db7e053188a32.tar.gz
podman-495884b3195de482dc610a2a002db7e053188a32.tar.bz2
podman-495884b3195de482dc610a2a002db7e053188a32.zip
use libnetwork from c/common
The libpod/network packages were moved to c/common so that buildah can use it as well. To prevent duplication use it in podman as well and remove it from here. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Diffstat (limited to 'libpod/network/internal/util/create.go')
-rw-r--r--libpod/network/internal/util/create.go42
1 files changed, 0 insertions, 42 deletions
diff --git a/libpod/network/internal/util/create.go b/libpod/network/internal/util/create.go
deleted file mode 100644
index cecfd7133..000000000
--- a/libpod/network/internal/util/create.go
+++ /dev/null
@@ -1,42 +0,0 @@
-package util
-
-import (
- "github.com/containers/podman/v3/libpod/define"
- "github.com/containers/podman/v3/libpod/network/types"
- "github.com/pkg/errors"
-)
-
-func CommonNetworkCreate(n NetUtil, network *types.Network) error {
- if network.Labels == nil {
- network.Labels = map[string]string{}
- }
- if network.Options == nil {
- network.Options = map[string]string{}
- }
- if network.IPAMOptions == nil {
- network.IPAMOptions = map[string]string{}
- }
-
- var name string
- var err error
- // validate the name when given
- if network.Name != "" {
- if !define.NameRegex.MatchString(network.Name) {
- return errors.Wrapf(define.RegexError, "network name %s invalid", network.Name)
- }
- if _, err := n.Network(network.Name); err == nil {
- return errors.Wrapf(define.ErrNetworkExists, "network name %s already used", network.Name)
- }
- } else {
- name, err = GetFreeDeviceName(n)
- if err != nil {
- return err
- }
- network.Name = name
- // also use the name as interface name when we create a bridge network
- if network.Driver == types.BridgeNetworkDriver && network.NetworkInterface == "" {
- network.NetworkInterface = name
- }
- }
- return nil
-}