summaryrefslogtreecommitdiff
path: root/cmd/podman/import.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2019-01-31 13:20:04 -0600
committerbaude <bbaude@redhat.com>2019-02-08 10:26:43 -0600
commit25a3923b61a5ca014318e6d957f68abd03947297 (patch)
tree2ccb4a0bd9bda70c1c258dcb1b8aca8961d9ad30 /cmd/podman/import.go
parent962850c6e0dfcee926af31fc0ad24f1f6c26f8ac (diff)
downloadpodman-25a3923b61a5ca014318e6d957f68abd03947297.tar.gz
podman-25a3923b61a5ca014318e6d957f68abd03947297.tar.bz2
podman-25a3923b61a5ca014318e6d957f68abd03947297.zip
Migrate to cobra CLI
We intend to migrate to the cobra cli from urfave/cli because the project is more well maintained. There are also some technical reasons as well which extend into our remote client work. Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'cmd/podman/import.go')
-rw-r--r--cmd/podman/import.go57
1 files changed, 27 insertions, 30 deletions
diff --git a/cmd/podman/import.go b/cmd/podman/import.go
index 661bd5a65..52d144eb3 100644
--- a/cmd/podman/import.go
+++ b/cmd/podman/import.go
@@ -3,47 +3,44 @@ package main
import (
"fmt"
+ "github.com/containers/libpod/cmd/podman/cliconfig"
"github.com/containers/libpod/libpod/adapter"
"github.com/pkg/errors"
- "github.com/urfave/cli"
+ "github.com/spf13/cobra"
)
var (
- importFlags = []cli.Flag{
- cli.StringSliceFlag{
- Name: "change, c",
- Usage: "Apply the following possible instructions to the created image (default []): CMD | ENTRYPOINT | ENV | EXPOSE | LABEL | STOPSIGNAL | USER | VOLUME | WORKDIR",
- },
- cli.StringFlag{
- Name: "message, m",
- Usage: "Set commit message for imported image",
- },
- cli.BoolFlag{
- Name: "quiet, q",
- Usage: "Suppress output",
- },
- }
+ importCommand cliconfig.ImportValues
+
importDescription = `Create a container image from the contents of the specified tarball (.tar, .tar.gz, .tgz, .bzip, .tar.xz, .txz).
Note remote tar balls can be specified, via web address.
Optionally tag the image. You can specify the instructions using the --change option.
`
- importCommand = cli.Command{
- Name: "import",
- Usage: "Import a tarball to create a filesystem image",
- Description: importDescription,
- Flags: sortFlags(importFlags),
- Action: importCmd,
- ArgsUsage: "TARBALL [REFERENCE]",
- OnUsageError: usageErrorHandler,
+ _importCommand = &cobra.Command{
+ Use: "import",
+ Short: "Import a tarball to create a filesystem image",
+ Long: importDescription,
+ RunE: func(cmd *cobra.Command, args []string) error {
+ importCommand.InputArgs = args
+ importCommand.GlobalFlags = MainGlobalOpts
+ return importCmd(&importCommand)
+ },
+ Example: "TARBALL [REFERENCE]",
}
)
-func importCmd(c *cli.Context) error {
- if err := validateFlags(c, importFlags); err != nil {
- return err
- }
+func init() {
+ importCommand.Command = _importCommand
+ flags := importCommand.Flags()
+ flags.StringSliceVarP(&importCommand.Change, "change", "c", []string{}, "Apply the following possible instructions to the created image (default []): CMD | ENTRYPOINT | ENV | EXPOSE | LABEL | STOPSIGNAL | USER | VOLUME | WORKDIR")
+ flags.StringVarP(&importCommand.Message, "message", "m", "", "Set commit message for imported image")
+ flags.BoolVarP(&importCommand.Quiet, "quiet", "q", false, "Suppress output")
+
+ rootCmd.AddCommand(importCommand.Command)
+}
- runtime, err := adapter.GetRuntime(c)
+func importCmd(c *cliconfig.ImportValues) error {
+ runtime, err := adapter.GetRuntime(&c.PodmanCommand)
if err != nil {
return errors.Wrapf(err, "could not get runtime")
}
@@ -54,7 +51,7 @@ func importCmd(c *cli.Context) error {
reference string
)
- args := c.Args()
+ args := c.InputArgs
switch len(args) {
case 0:
return errors.Errorf("need to give the path to the tarball, or must specify a tarball of '-' for stdin")
@@ -71,7 +68,7 @@ func importCmd(c *cli.Context) error {
return err
}
- quiet := c.Bool("quiet")
+ quiet := c.Quiet
if runtime.Remote {
quiet = false
}