podmanv2 add pre-run to each commmand

each container command needs a prerune because it is not part of the containers subcommand yet

Signed-off-by: Brent Baude <bbaude@redhat.com>
This commit is contained in:
Brent Baude
2020-03-25 19:19:55 -05:00
parent ff0124aee1
commit 06e2a5dd86
7 changed files with 35 additions and 28 deletions

View File

@ -15,10 +15,11 @@ import (
var ( var (
killDescription = "The main process inside each container specified will be sent SIGKILL, or any signal specified with option --signal." killDescription = "The main process inside each container specified will be sent SIGKILL, or any signal specified with option --signal."
killCommand = &cobra.Command{ killCommand = &cobra.Command{
Use: "kill [flags] CONTAINER [CONTAINER...]", Use: "kill [flags] CONTAINER [CONTAINER...]",
Short: "Kill one or more running containers with a specific signal", Short: "Kill one or more running containers with a specific signal",
Long: killDescription, Long: killDescription,
RunE: kill, RunE: kill,
PersistentPreRunE: preRunE,
Args: func(cmd *cobra.Command, args []string) error { Args: func(cmd *cobra.Command, args []string) error {
return parse.CheckAllLatestAndCIDFile(cmd, args, false, false) return parse.CheckAllLatestAndCIDFile(cmd, args, false, false)
}, },

View File

@ -15,10 +15,11 @@ import (
var ( var (
pauseDescription = `Pauses one or more running containers. The container name or ID can be used.` pauseDescription = `Pauses one or more running containers. The container name or ID can be used.`
pauseCommand = &cobra.Command{ pauseCommand = &cobra.Command{
Use: "pause [flags] CONTAINER [CONTAINER...]", Use: "pause [flags] CONTAINER [CONTAINER...]",
Short: "Pause all the processes in one or more containers", Short: "Pause all the processes in one or more containers",
Long: pauseDescription, Long: pauseDescription,
RunE: pause, RunE: pause,
PersistentPreRunE: preRunE,
Example: `podman pause mywebserver Example: `podman pause mywebserver
podman pause 860a4b23 podman pause 860a4b23
podman pause -a`, podman pause -a`,

View File

@ -18,10 +18,11 @@ var (
A timeout before forcibly stopping can be set, but defaults to 10 seconds.` A timeout before forcibly stopping can be set, but defaults to 10 seconds.`
restartCommand = &cobra.Command{ restartCommand = &cobra.Command{
Use: "restart [flags] CONTAINER [CONTAINER...]", Use: "restart [flags] CONTAINER [CONTAINER...]",
Short: "Restart one or more containers", Short: "Restart one or more containers",
Long: restartDescription, Long: restartDescription,
RunE: restart, RunE: restart,
PersistentPreRunE: preRunE,
Args: func(cmd *cobra.Command, args []string) error { Args: func(cmd *cobra.Command, args []string) error {
return parse.CheckAllLatestAndCIDFile(cmd, args, false, false) return parse.CheckAllLatestAndCIDFile(cmd, args, false, false)
}, },

View File

@ -19,10 +19,11 @@ var (
Command does not remove images. Running or unusable containers will not be removed without the -f option.` Command does not remove images. Running or unusable containers will not be removed without the -f option.`
rmCommand = &cobra.Command{ rmCommand = &cobra.Command{
Use: "rm [flags] CONTAINER [CONTAINER...]", Use: "rm [flags] CONTAINER [CONTAINER...]",
Short: "Remove one or more containers", Short: "Remove one or more containers",
Long: rmDescription, Long: rmDescription,
RunE: rm, RunE: rm,
PersistentPreRunE: preRunE,
Args: func(cmd *cobra.Command, args []string) error { Args: func(cmd *cobra.Command, args []string) error {
return parse.CheckAllLatestAndCIDFile(cmd, args, false, true) return parse.CheckAllLatestAndCIDFile(cmd, args, false, true)
}, },

View File

@ -18,10 +18,11 @@ var (
A timeout to forcibly stop the container can also be set but defaults to 10 seconds otherwise.` A timeout to forcibly stop the container can also be set but defaults to 10 seconds otherwise.`
stopCommand = &cobra.Command{ stopCommand = &cobra.Command{
Use: "stop [flags] CONTAINER [CONTAINER...]", Use: "stop [flags] CONTAINER [CONTAINER...]",
Short: "Stop one or more containers", Short: "Stop one or more containers",
Long: stopDescription, Long: stopDescription,
RunE: stop, RunE: stop,
PersistentPreRunE: preRunE,
Args: func(cmd *cobra.Command, args []string) error { Args: func(cmd *cobra.Command, args []string) error {
return parse.CheckAllLatestAndCIDFile(cmd, args, false, true) return parse.CheckAllLatestAndCIDFile(cmd, args, false, true)
}, },

View File

@ -15,10 +15,11 @@ import (
var ( var (
unpauseDescription = `Unpauses one or more previously paused containers. The container name or ID can be used.` unpauseDescription = `Unpauses one or more previously paused containers. The container name or ID can be used.`
unpauseCommand = &cobra.Command{ unpauseCommand = &cobra.Command{
Use: "unpause [flags] CONTAINER [CONTAINER...]", Use: "unpause [flags] CONTAINER [CONTAINER...]",
Short: "Unpause the processes in one or more containers", Short: "Unpause the processes in one or more containers",
Long: unpauseDescription, Long: unpauseDescription,
RunE: unpause, RunE: unpause,
PersistentPreRunE: preRunE,
Example: `podman unpause ctrID Example: `podman unpause ctrID
podman unpause --all`, podman unpause --all`,
} }

View File

@ -18,10 +18,11 @@ var (
waitDescription = `Block until one or more containers stop and then print their exit codes. waitDescription = `Block until one or more containers stop and then print their exit codes.
` `
waitCommand = &cobra.Command{ waitCommand = &cobra.Command{
Use: "wait [flags] CONTAINER [CONTAINER...]", Use: "wait [flags] CONTAINER [CONTAINER...]",
Short: "Block on one or more containers", Short: "Block on one or more containers",
Long: waitDescription, Long: waitDescription,
RunE: wait, RunE: wait,
PersistentPreRunE: preRunE,
Args: func(cmd *cobra.Command, args []string) error { Args: func(cmd *cobra.Command, args []string) error {
return parse.CheckAllLatestAndCIDFile(cmd, args, false, false) return parse.CheckAllLatestAndCIDFile(cmd, args, false, false)
}, },