summaryrefslogtreecommitdiff
path: root/cmd/podman/restart.go
diff options
context:
space:
mode:
authorBrent Baude <bbaude@redhat.com>2020-04-16 12:25:26 -0500
committerBrent Baude <bbaude@redhat.com>2020-04-16 15:53:58 -0500
commit241326a9a8c20ad7f2bcf651416b836e7778e090 (patch)
tree4001e8e47a022bb1b9bfbf2332c42e1aeb802f9e /cmd/podman/restart.go
parent88c6fd06cd54fb9a8826306dfdf1a77e400de5de (diff)
downloadpodman-241326a9a8c20ad7f2bcf651416b836e7778e090.tar.gz
podman-241326a9a8c20ad7f2bcf651416b836e7778e090.tar.bz2
podman-241326a9a8c20ad7f2bcf651416b836e7778e090.zip
Podman V2 birth
remote podman v1 and replace with podman v2. Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'cmd/podman/restart.go')
-rw-r--r--cmd/podman/restart.go77
1 files changed, 0 insertions, 77 deletions
diff --git a/cmd/podman/restart.go b/cmd/podman/restart.go
deleted file mode 100644
index 4ee043442..000000000
--- a/cmd/podman/restart.go
+++ /dev/null
@@ -1,77 +0,0 @@
-package main
-
-import (
- "fmt"
-
- "github.com/containers/libpod/cmd/podman/cliconfig"
- "github.com/containers/libpod/libpod/define"
- "github.com/containers/libpod/pkg/adapter"
- "github.com/pkg/errors"
- "github.com/spf13/cobra"
-)
-
-var (
- restartCommand cliconfig.RestartValues
- restartDescription = fmt.Sprintf(`Restarts one or more running containers. The container ID or name can be used.
-
- A timeout before forcibly stopping can be set, but defaults to %d seconds.`, defaultContainerConfig.Engine.StopTimeout)
- _restartCommand = &cobra.Command{
- Use: "restart [flags] CONTAINER [CONTAINER...]",
- Short: "Restart one or more containers",
- Long: restartDescription,
- RunE: func(cmd *cobra.Command, args []string) error {
- restartCommand.InputArgs = args
- restartCommand.GlobalFlags = MainGlobalOpts
- return restartCmd(&restartCommand)
- },
- Args: func(cmd *cobra.Command, args []string) error {
- return checkAllLatestAndCIDFile(cmd, args, false, false)
- },
- Example: `podman restart ctrID
- podman restart --latest
- podman restart ctrID1 ctrID2`,
- }
-)
-
-func init() {
- restartCommand.Command = _restartCommand
- restartCommand.SetHelpTemplate(HelpTemplate())
- restartCommand.SetUsageTemplate(UsageTemplate())
- flags := restartCommand.Flags()
- flags.BoolVarP(&restartCommand.All, "all", "a", false, "Restart all non-running containers")
- flags.BoolVarP(&restartCommand.Latest, "latest", "l", false, "Act on the latest container podman is aware of")
- flags.BoolVar(&restartCommand.Running, "running", false, "Restart only running containers when --all is used")
- flags.UintVarP(&restartCommand.Timeout, "time", "t", defaultContainerConfig.Engine.StopTimeout, "Seconds to wait for stop before killing the container")
-
- markFlagHiddenForRemoteClient("latest", flags)
- flags.SetNormalizeFunc(aliasFlags)
-}
-
-func restartCmd(c *cliconfig.RestartValues) error {
- all := c.All
- if len(c.InputArgs) < 1 && !c.Latest && !all {
- return errors.Wrapf(define.ErrInvalidArg, "you must provide at least one container name or ID")
- }
-
- runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand)
- if err != nil {
- return errors.Wrapf(err, "error creating libpod runtime")
- }
- defer runtime.DeferredShutdown(false)
-
- ok, failures, err := runtime.Restart(getContext(), c)
- if err != nil {
- if errors.Cause(err) == define.ErrNoSuchCtr {
- if len(c.InputArgs) > 1 {
- exitCode = define.ExecErrorCodeGeneric
- } else {
- exitCode = 1
- }
- }
- return err
- }
- if len(failures) > 0 {
- exitCode = define.ExecErrorCodeGeneric
- }
- return printCmdResults(ok, failures)
-}