summaryrefslogtreecommitdiff
path: root/cmd/podmanV2/common/util.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podmanV2/common/util.go')
-rw-r--r--cmd/podmanV2/common/util.go43
1 files changed, 0 insertions, 43 deletions
diff --git a/cmd/podmanV2/common/util.go b/cmd/podmanV2/common/util.go
deleted file mode 100644
index 47bbe12fa..000000000
--- a/cmd/podmanV2/common/util.go
+++ /dev/null
@@ -1,43 +0,0 @@
-package common
-
-import (
- "strconv"
-
- "github.com/cri-o/ocicni/pkg/ocicni"
- "github.com/docker/go-connections/nat"
- "github.com/pkg/errors"
-)
-
-// createPortBindings iterates ports mappings and exposed ports into a format CNI understands
-func createPortBindings(ports []string) ([]ocicni.PortMapping, error) {
- // TODO wants someone to rewrite this code in the future
- var portBindings []ocicni.PortMapping
- // The conversion from []string to natBindings is temporary while mheon reworks the port
- // deduplication code. Eventually that step will not be required.
- _, natBindings, err := nat.ParsePortSpecs(ports)
- if err != nil {
- return nil, err
- }
- for containerPb, hostPb := range natBindings {
- var pm ocicni.PortMapping
- pm.ContainerPort = int32(containerPb.Int())
- for _, i := range hostPb {
- var hostPort int
- var err error
- pm.HostIP = i.HostIP
- if i.HostPort == "" {
- hostPort = containerPb.Int()
- } else {
- hostPort, err = strconv.Atoi(i.HostPort)
- if err != nil {
- return nil, errors.Wrapf(err, "unable to convert host port to integer")
- }
- }
-
- pm.HostPort = int32(hostPort)
- pm.Protocol = containerPb.Proto()
- portBindings = append(portBindings, pm)
- }
- }
- return portBindings, nil
-}