diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2017-12-15 16:58:36 -0500 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2017-12-18 16:46:05 +0000 |
commit | 5770dc2640c216525ab84031e3712fcc46b3b087 (patch) | |
tree | 8a1c5c4e4a6ce6a35a3767247623a62bfd698f77 /cmd/kpod/stop.go | |
parent | de3468e120d489d046c08dad72ba2262e222ccb1 (diff) | |
download | podman-5770dc2640c216525ab84031e3712fcc46b3b087.tar.gz podman-5770dc2640c216525ab84031e3712fcc46b3b087.tar.bz2 podman-5770dc2640c216525ab84031e3712fcc46b3b087.zip |
Rename all references to kpod to podman
The decision is in, kpod is going to be named podman.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Closes: #145
Approved by: umohnani8
Diffstat (limited to 'cmd/kpod/stop.go')
-rw-r--r-- | cmd/kpod/stop.go | 104 |
1 files changed, 0 insertions, 104 deletions
diff --git a/cmd/kpod/stop.go b/cmd/kpod/stop.go deleted file mode 100644 index f18fbc232..000000000 --- a/cmd/kpod/stop.go +++ /dev/null @@ -1,104 +0,0 @@ -package main - -import ( - "fmt" - "os" - - "github.com/pkg/errors" - "github.com/projectatomic/libpod/libpod" - "github.com/sirupsen/logrus" - "github.com/urfave/cli" -) - -var ( - defaultTimeout int64 = 10 - stopFlags = []cli.Flag{ - cli.Int64Flag{ - Name: "timeout, t", - Usage: "Seconds to wait for stop before killing the container", - Value: defaultTimeout, - }, - cli.BoolFlag{ - Name: "all, a", - Usage: "stop all running containers", - }, - } - stopDescription = ` - kpod stop - - Stops one or more running containers. The container name or ID can be used. - A timeout to forcibly stop the container can also be set but defaults to 10 - seconds otherwise. -` - - stopCommand = cli.Command{ - Name: "stop", - Usage: "Stop one or more containers", - Description: stopDescription, - Flags: stopFlags, - Action: stopCmd, - ArgsUsage: "CONTAINER-NAME [CONTAINER-NAME ...]", - } -) - -func stopCmd(c *cli.Context) error { - args := c.Args() - stopTimeout := c.Int64("timeout") - if c.Bool("all") && len(args) > 0 { - return errors.Errorf("no arguments are needed with -a") - } - if len(args) < 1 && !c.Bool("all") { - return errors.Errorf("you must provide at least one container name or id") - } - if err := validateFlags(c, stopFlags); err != nil { - return err - } - - runtime, err := getRuntime(c) - if err != nil { - return errors.Wrapf(err, "could not get runtime") - } - defer runtime.Shutdown(false) - - logrus.Debugf("Stopping containers with timeout %d", stopTimeout) - - var filterFuncs []libpod.ContainerFilter - var containers []*libpod.Container - var lastError error - - if c.Bool("all") { - // only get running containers - filterFuncs = append(filterFuncs, func(c *libpod.Container) bool { - state, _ := c.State() - return state == libpod.ContainerStateRunning - }) - containers, err = runtime.GetContainers(filterFuncs...) - if err != nil { - return errors.Wrapf(err, "unable to get running containers") - } - } else { - for _, i := range args { - container, err := runtime.LookupContainer(i) - if err != nil { - if lastError != nil { - fmt.Fprintln(os.Stderr, lastError) - } - lastError = errors.Wrapf(err, "unable to find container %s", i) - continue - } - containers = append(containers, container) - } - } - - for _, ctr := range containers { - if err := ctr.Stop(stopTimeout); err != nil { - if lastError != nil { - fmt.Fprintln(os.Stderr, lastError) - } - lastError = errors.Wrapf(err, "failed to stop container %v", ctr.ID()) - } else { - fmt.Println(ctr.ID()) - } - } - return lastError -} |