summaryrefslogtreecommitdiff
path: root/cmd/podman/exists.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-02-08 20:12:38 +0100
committerGitHub <noreply@github.com>2019-02-08 20:12:38 +0100
commitafd4d5f4a4b05f421e6f336b4d74a0d808be57ed (patch)
tree2ccb4a0bd9bda70c1c258dcb1b8aca8961d9ad30 /cmd/podman/exists.go
parent962850c6e0dfcee926af31fc0ad24f1f6c26f8ac (diff)
parent25a3923b61a5ca014318e6d957f68abd03947297 (diff)
downloadpodman-afd4d5f4a4b05f421e6f336b4d74a0d808be57ed.tar.gz
podman-afd4d5f4a4b05f421e6f336b4d74a0d808be57ed.tar.bz2
podman-afd4d5f4a4b05f421e6f336b4d74a0d808be57ed.zip
Merge pull request #2274 from baude/cobraprep
Migrate to cobra CLI
Diffstat (limited to 'cmd/podman/exists.go')
-rw-r--r--cmd/podman/exists.go96
1 files changed, 55 insertions, 41 deletions
diff --git a/cmd/podman/exists.go b/cmd/podman/exists.go
index a7601aaa2..a21e8fcf8 100644
--- a/cmd/podman/exists.go
+++ b/cmd/podman/exists.go
@@ -1,6 +1,8 @@
package main
import (
+ "github.com/containers/libpod/cmd/podman/cliconfig"
+ "github.com/spf13/cobra"
"os"
"github.com/containers/libpod/cmd/podman/libpodruntime"
@@ -8,66 +10,78 @@ import (
"github.com/containers/libpod/libpod/adapter"
"github.com/containers/libpod/libpod/image"
"github.com/pkg/errors"
- "github.com/urfave/cli"
)
var (
+ imageExistsCommand cliconfig.ImageExistsValues
+ containerExistsCommand cliconfig.ContainerExistsValues
+ podExistsCommand cliconfig.PodExistsValues
+
imageExistsDescription = `
podman image exists
Check if an image exists in local storage
`
-
- imageExistsCommand = cli.Command{
- Name: "exists",
- Usage: "Check if an image exists in local storage",
- Description: imageExistsDescription,
- Action: imageExistsCmd,
- ArgsUsage: "IMAGE-NAME",
- OnUsageError: usageErrorHandler,
- }
-)
-
-var (
containerExistsDescription = `
podman container exists
Check if a container exists in local storage
`
-
- containerExistsCommand = cli.Command{
- Name: "exists",
- Usage: "Check if a container exists in local storage",
- Description: containerExistsDescription,
- Action: containerExistsCmd,
- ArgsUsage: "CONTAINER-NAME",
- OnUsageError: usageErrorHandler,
- }
-)
-
-var (
podExistsDescription = `
podman pod exists
Check if a pod exists in local storage
`
+ _imageExistsCommand = &cobra.Command{
+ Use: "exists",
+ Short: "Check if an image exists in local storage",
+ Long: imageExistsDescription,
+ RunE: func(cmd *cobra.Command, args []string) error {
+ imageExistsCommand.InputArgs = args
+ imageExistsCommand.GlobalFlags = MainGlobalOpts
+ return imageExistsCmd(&imageExistsCommand)
+ },
+ Example: "IMAGE-NAME",
+ }
+
+ _containerExistsCommand = &cobra.Command{
+ Use: "exists",
+ Short: "Check if a container exists in local storage",
+ Long: containerExistsDescription,
+ RunE: func(cmd *cobra.Command, args []string) error {
+ containerExistsCommand.InputArgs = args
+ containerExistsCommand.GlobalFlags = MainGlobalOpts
+ return containerExistsCmd(&containerExistsCommand)
- podExistsCommand = cli.Command{
- Name: "exists",
- Usage: "Check if a pod exists in local storage",
- Description: podExistsDescription,
- Action: podExistsCmd,
- ArgsUsage: "POD-NAME",
- OnUsageError: usageErrorHandler,
+ },
+ Example: "CONTAINER-NAME",
+ }
+
+ _podExistsCommand = &cobra.Command{
+ Use: "exists",
+ Short: "Check if a pod exists in local storage",
+ Long: podExistsDescription,
+ RunE: func(cmd *cobra.Command, args []string) error {
+ podExistsCommand.InputArgs = args
+ podExistsCommand.GlobalFlags = MainGlobalOpts
+ return podExistsCmd(&podExistsCommand)
+ },
+ Example: "POD-NAME",
}
)
-func imageExistsCmd(c *cli.Context) error {
- args := c.Args()
+func init() {
+ imageExistsCommand.Command = _imageExistsCommand
+ containerExistsCommand.Command = _containerExistsCommand
+ podExistsCommand.Command = _podExistsCommand
+}
+
+func imageExistsCmd(c *cliconfig.ImageExistsValues) error {
+ args := c.InputArgs
if len(args) > 1 || len(args) < 1 {
return errors.New("you may only check for the existence of one image at a time")
}
- runtime, err := adapter.GetRuntime(c)
+ runtime, err := adapter.GetRuntime(&c.PodmanCommand)
if err != nil {
return errors.Wrapf(err, "could not get runtime")
}
@@ -83,12 +97,12 @@ func imageExistsCmd(c *cli.Context) error {
return nil
}
-func containerExistsCmd(c *cli.Context) error {
- args := c.Args()
+func containerExistsCmd(c *cliconfig.ContainerExistsValues) error {
+ args := c.InputArgs
if len(args) > 1 || len(args) < 1 {
return errors.New("you may only check for the existence of one container at a time")
}
- runtime, err := adapter.GetRuntime(c)
+ runtime, err := adapter.GetRuntime(&c.PodmanCommand)
if err != nil {
return errors.Wrapf(err, "could not get runtime")
}
@@ -102,12 +116,12 @@ func containerExistsCmd(c *cli.Context) error {
return nil
}
-func podExistsCmd(c *cli.Context) error {
- args := c.Args()
+func podExistsCmd(c *cliconfig.PodExistsValues) error {
+ args := c.InputArgs
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)
+ runtime, err := libpodruntime.GetRuntime(&c.PodmanCommand)
if err != nil {
return errors.Wrapf(err, "could not get runtime")
}