summaryrefslogtreecommitdiff
path: root/cmd/podman/import.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/import.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/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
}