Merge pull request #6107 from sujil02/enableport

Enables port test
This commit is contained in:
OpenShift Merge Robot
2020-05-07 10:01:22 +02:00
committed by GitHub
3 changed files with 45 additions and 11 deletions

View File

@ -11,6 +11,7 @@ import (
"github.com/cri-o/ocicni/pkg/ocicni"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
var (
@ -28,18 +29,25 @@ var (
podman port ctrID 80/tcp
podman port --latest 80`,
}
containerPortCommand = &cobra.Command{
Use: "port [flags] CONTAINER [PORT]",
Short: portCommand.Short,
Long: portDescription,
RunE: portCommand.RunE,
Args: func(cmd *cobra.Command, args []string) error {
return parse.CheckAllLatestAndCIDFile(cmd, args, true, false)
},
Example: `podman container port --all
podman container port --latest 80`,
}
)
var (
portOpts entities.ContainerPortOptions
)
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode},
Command: portCommand,
})
flags := portCommand.Flags()
func portFlags(flags *pflag.FlagSet) {
flags.BoolVarP(&portOpts.All, "all", "a", false, "Display port information for all containers")
flags.BoolVarP(&portOpts.Latest, "latest", "l", false, "Act on the latest container podman is aware of")
if registry.IsRemote() {
@ -47,6 +55,26 @@ func init() {
}
}
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode},
Command: portCommand,
})
flags := portCommand.Flags()
portFlags(flags)
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode},
Command: containerPortCommand,
Parent: containerCmd,
})
containerPortflags := containerPortCommand.Flags()
portFlags(containerPortflags)
}
func port(cmd *cobra.Command, args []string) error {
var (
container string

View File

@ -30,13 +30,20 @@ func CheckAllLatestAndCIDFile(c *cobra.Command, args []string, ignoreArgLen bool
return errors.Errorf("--all and --latest cannot be used together")
}
if (argLen > 0) && specifiedAll {
return errors.Errorf("no arguments are needed with --all")
}
if ignoreArgLen {
return nil
}
if (argLen > 0) && (specifiedAll || specifiedLatest) {
return errors.Errorf("no arguments are needed with --all or --latest")
} else if cidfile && (argLen > 0) && (specifiedAll || specifiedLatest || specifiedCIDFile) {
return errors.Errorf("no arguments are needed with --all, --latest or --cidfile")
if argLen > 0 {
if specifiedLatest {
return errors.Errorf("no arguments are needed with --latest")
} else if cidfile && (specifiedLatest || specifiedCIDFile) {
return errors.Errorf("no arguments are needed with --latest or --cidfile")
}
}
if specifiedCIDFile {

View File

@ -20,7 +20,6 @@ var _ = Describe("Podman port", func() {
)
BeforeEach(func() {
Skip(v2fail)
tempdir, err = CreateTempDirInTempDir()
if err != nil {
os.Exit(1)