diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-04-21 10:19:33 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-21 10:19:33 -0400 |
commit | 0cd120507a52a1a909fe7bb345c765c4bd3a6b87 (patch) | |
tree | 317a3f1793b3ef4754940c73d25c93e94892df6e /pkg/domain/infra/abi/containers.go | |
parent | 84bbdcef5d3f6f431fe8fbf9e59896d7fc311111 (diff) | |
parent | ae5e7e7e782a96107d7c0254b55a03dac3dcce76 (diff) | |
download | podman-0cd120507a52a1a909fe7bb345c765c4bd3a6b87.tar.gz podman-0cd120507a52a1a909fe7bb345c765c4bd3a6b87.tar.bz2 podman-0cd120507a52a1a909fe7bb345c765c4bd3a6b87.zip |
Merge pull request #5902 from baude/v2port
v2podman port
Diffstat (limited to 'pkg/domain/infra/abi/containers.go')
-rw-r--r-- | pkg/domain/infra/abi/containers.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/pkg/domain/infra/abi/containers.go b/pkg/domain/infra/abi/containers.go index e71ceb536..73a0d8ec3 100644 --- a/pkg/domain/infra/abi/containers.go +++ b/pkg/domain/infra/abi/containers.go @@ -929,3 +929,31 @@ func (ic *ContainerEngine) ContainerUnmount(ctx context.Context, nameOrIds []str func (ic *ContainerEngine) Config(_ context.Context) (*config.Config, error) { return ic.Libpod.GetConfig() } + +func (ic *ContainerEngine) ContainerPort(ctx context.Context, nameOrId string, options entities.ContainerPortOptions) ([]*entities.ContainerPortReport, error) { + var reports []*entities.ContainerPortReport + ctrs, err := getContainersByContext(options.All, false, []string{nameOrId}, ic.Libpod) + if err != nil { + return nil, err + } + for _, con := range ctrs { + state, err := con.State() + if err != nil { + return nil, err + } + if state != define.ContainerStateRunning { + continue + } + portmappings, err := con.PortMappings() + if err != nil { + return nil, err + } + if len(portmappings) > 0 { + reports = append(reports, &entities.ContainerPortReport{ + Id: con.ID(), + Ports: portmappings, + }) + } + } + return reports, nil +} |