diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2018-12-03 12:21:44 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-03 12:21:44 -0800 |
commit | 5f6ad82524ca7a3281c8464c84b4f9be4ff90aef (patch) | |
tree | d036677ca9be92e404858312b99f84b312673263 /cmd/podman | |
parent | 03aafff4ef0ebd8fb03836d59dc2dacdc233696f (diff) | |
parent | 318bf7017bcb82da9f73cfce9e3a963b61252788 (diff) | |
download | podman-5f6ad82524ca7a3281c8464c84b4f9be4ff90aef.tar.gz podman-5f6ad82524ca7a3281c8464c84b4f9be4ff90aef.tar.bz2 podman-5f6ad82524ca7a3281c8464c84b4f9be4ff90aef.zip |
Merge pull request #1913 from baude/podexists
podman pod exists
Diffstat (limited to 'cmd/podman')
-rw-r--r-- | cmd/podman/exists.go | 37 | ||||
-rw-r--r-- | cmd/podman/pod.go | 1 |
2 files changed, 38 insertions, 0 deletions
diff --git a/cmd/podman/exists.go b/cmd/podman/exists.go index 2f7b7c185..2e2559ec7 100644 --- a/cmd/podman/exists.go +++ b/cmd/podman/exists.go @@ -44,6 +44,23 @@ var ( } ) +var ( + podExistsDescription = ` + podman pod exists + + Check if a pod exists in local storage +` + + podExistsCommand = cli.Command{ + Name: "exists", + Usage: "Check if a pod exists in local storage", + Description: podExistsDescription, + Action: podExistsCmd, + ArgsUsage: "POD-NAME", + OnUsageError: usageErrorHandler, + } +) + func imageExistsCmd(c *cli.Context) error { args := c.Args() if len(args) > 1 || len(args) < 1 { @@ -81,3 +98,23 @@ func containerExistsCmd(c *cli.Context) error { } return nil } + +func podExistsCmd(c *cli.Context) error { + args := c.Args() + if len(args) > 1 || len(args) < 1 { + return errors.New("you may only check for the existence of one pod at a time") + } + runtime, err := libpodruntime.GetRuntime(c) + if err != nil { + return errors.Wrapf(err, "could not get runtime") + } + defer runtime.Shutdown(false) + + if _, err := runtime.LookupPod(args[0]); err != nil { + if errors.Cause(err) == libpod.ErrNoSuchPod { + os.Exit(1) + } + return err + } + return nil +} diff --git a/cmd/podman/pod.go b/cmd/podman/pod.go index 0c6ec5e8c..a30361134 100644 --- a/cmd/podman/pod.go +++ b/cmd/podman/pod.go @@ -11,6 +11,7 @@ Pods are a group of one or more containers sharing the same network, pid and ipc ` podSubCommands = []cli.Command{ podCreateCommand, + podExistsCommand, podInspectCommand, podKillCommand, podPauseCommand, |