Skip to content

Commit

Permalink
Merge pull request #11232 from Luap99/network
Browse files Browse the repository at this point in the history
Network interface
  • Loading branch information
openshift-merge-robot authored Aug 24, 2021
2 parents e20ec47 + c0b1edd commit e9daaf6
Show file tree
Hide file tree
Showing 40 changed files with 5,577 additions and 45 deletions.
5 changes: 3 additions & 2 deletions cmd/podman/common/create_opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/containers/common/pkg/config"
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/libpod/network/types"
"github.com/containers/podman/v3/pkg/api/handlers"
"github.com/containers/podman/v3/pkg/cgroups"
"github.com/containers/podman/v3/pkg/domain/entities"
Expand Down Expand Up @@ -150,7 +151,7 @@ func ContainerCreateToContainerCLIOpts(cc handlers.CreateContainerConfig, rtc *c
cappDrop []string
entrypoint *string
init bool
specPorts []specgen.PortMapping
specPorts []types.PortMapping
)

if cc.HostConfig.Init != nil {
Expand Down Expand Up @@ -240,7 +241,7 @@ func ContainerCreateToContainerCLIOpts(cc handlers.CreateContainerConfig, rtc *c
if err != nil {
return nil, nil, err
}
tmpPort := specgen.PortMapping{
tmpPort := types.PortMapping{
HostIP: pb.HostIP,
ContainerPort: uint16(port.Int()),
HostPort: uint16(hostport),
Expand Down
10 changes: 5 additions & 5 deletions cmd/podman/common/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strconv"
"strings"

"github.com/containers/podman/v3/pkg/specgen"
"github.com/containers/podman/v3/libpod/network/types"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
Expand Down Expand Up @@ -90,10 +90,10 @@ func createExpose(expose []string) (map[uint16]string, error) {
}

// CreatePortBindings iterates ports mappings into SpecGen format.
func CreatePortBindings(ports []string) ([]specgen.PortMapping, error) {
func CreatePortBindings(ports []string) ([]types.PortMapping, error) {
// --publish is formatted as follows:
// [[hostip:]hostport[-endPort]:]containerport[-endPort][/protocol]
toReturn := make([]specgen.PortMapping, 0, len(ports))
toReturn := make([]types.PortMapping, 0, len(ports))

for _, p := range ports {
var (
Expand Down Expand Up @@ -169,8 +169,8 @@ func CreatePortBindings(ports []string) ([]specgen.PortMapping, error) {

// parseSplitPort parses individual components of the --publish flag to produce
// a single port mapping in SpecGen format.
func parseSplitPort(hostIP, hostPort *string, ctrPort string, protocol *string) (specgen.PortMapping, error) {
newPort := specgen.PortMapping{}
func parseSplitPort(hostIP, hostPort *string, ctrPort string, protocol *string) (types.PortMapping, error) {
newPort := types.PortMapping{}
if ctrPort == "" {
return newPort, errors.Errorf("must provide a non-empty container port to publish")
}
Expand Down
10 changes: 10 additions & 0 deletions libpod/network/cni/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
This package abstracts CNI from libpod.
It implements the `ContainerNetwork` interface defined in [libpod/network/types/network.go](../types/network.go) for the CNI backend.


## Testing
Run the tests with:
```
go test -v -mod=vendor -cover ./libpod/network/cni/
```
Run the tests as root to also test setup/teardown. This will execute CNI and therefore the cni plugins have to be installed.
Loading

0 comments on commit e9daaf6

Please sign in to comment.