summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-05-12 06:34:26 -0700
committerGitHub <noreply@github.com>2020-05-12 06:34:26 -0700
commit46cf421ed73315436aab4aba8ca47ba6a50339d3 (patch)
tree12ef7acc9ac9da9ec9c674b4c1d39aaafff37daa
parent07f775d161ef642cbbe5dc98071aa04d9312b17e (diff)
parenta36e8d8eaa94458325afe19d7af7f29bf7fffbcd (diff)
downloadpodman-46cf421ed73315436aab4aba8ca47ba6a50339d3.tar.gz
podman-46cf421ed73315436aab4aba8ca47ba6a50339d3.tar.bz2
podman-46cf421ed73315436aab4aba8ca47ba6a50339d3.zip
Merge pull request #6181 from baude/v2remoteport
add port to podman remote command
-rw-r--r--cmd/podman/containers/port.go4
-rw-r--r--pkg/domain/infra/tunnel/containers.go24
2 files changed, 25 insertions, 3 deletions
diff --git a/cmd/podman/containers/port.go b/cmd/podman/containers/port.go
index ec0ddf838..d058a6aaf 100644
--- a/cmd/podman/containers/port.go
+++ b/cmd/podman/containers/port.go
@@ -57,7 +57,7 @@ func portFlags(flags *pflag.FlagSet) {
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
- Mode: []entities.EngineMode{entities.ABIMode},
+ Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: portCommand,
})
@@ -65,7 +65,7 @@ func init() {
portFlags(flags)
registry.Commands = append(registry.Commands, registry.CliCommand{
- Mode: []entities.EngineMode{entities.ABIMode},
+ Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: containerPortCommand,
Parent: containerCmd,
})
diff --git a/pkg/domain/infra/tunnel/containers.go b/pkg/domain/infra/tunnel/containers.go
index 49a3069d6..028e3bc5f 100644
--- a/pkg/domain/infra/tunnel/containers.go
+++ b/pkg/domain/infra/tunnel/containers.go
@@ -381,7 +381,29 @@ func (ic *ContainerEngine) Config(_ context.Context) (*config.Config, error) {
}
func (ic *ContainerEngine) ContainerPort(ctx context.Context, nameOrId string, options entities.ContainerPortOptions) ([]*entities.ContainerPortReport, error) {
- return nil, errors.New("not implemented")
+ var (
+ reports []*entities.ContainerPortReport
+ namesOrIds []string
+ )
+ if len(nameOrId) > 0 {
+ namesOrIds = append(namesOrIds, nameOrId)
+ }
+ ctrs, err := getContainersByContext(ic.ClientCxt, options.All, namesOrIds)
+ if err != nil {
+ return nil, err
+ }
+ for _, con := range ctrs {
+ if con.State != define.ContainerStateRunning.String() {
+ continue
+ }
+ if len(con.Ports) > 0 {
+ reports = append(reports, &entities.ContainerPortReport{
+ Id: con.ID,
+ Ports: con.Ports,
+ })
+ }
+ }
+ return reports, nil
}
func (ic *ContainerEngine) ContainerCp(ctx context.Context, source, dest string, options entities.ContainerCpOptions) (*entities.ContainerCpReport, error) {