Merge pull request #6181 from baude/v2remoteport

add port to podman remote command
This commit is contained in:
OpenShift Merge Robot
2020-05-12 06:34:26 -07:00
committed by GitHub
2 changed files with 25 additions and 3 deletions

View File

@ -57,7 +57,7 @@ func portFlags(flags *pflag.FlagSet) {
func init() { func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{ registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode}, Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: portCommand, Command: portCommand,
}) })
@ -65,7 +65,7 @@ func init() {
portFlags(flags) portFlags(flags)
registry.Commands = append(registry.Commands, registry.CliCommand{ registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode}, Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: containerPortCommand, Command: containerPortCommand,
Parent: containerCmd, Parent: containerCmd,
}) })

View File

@ -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) { 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) { func (ic *ContainerEngine) ContainerCp(ctx context.Context, source, dest string, options entities.ContainerCpOptions) (*entities.ContainerCpReport, error) {