summaryrefslogtreecommitdiff
path: root/cmd/podman/import.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-04-16 14:04:58 -0700
committerGitHub <noreply@github.com>2020-04-16 14:04:58 -0700
commit0d2b5532c417c58bd24e71a56c5c55b43e423a59 (patch)
tree4001e8e47a022bb1b9bfbf2332c42e1aeb802f9e /cmd/podman/import.go
parent88c6fd06cd54fb9a8826306dfdf1a77e400de5de (diff)
parent241326a9a8c20ad7f2bcf651416b836e7778e090 (diff)
downloadpodman-0d2b5532c417c58bd24e71a56c5c55b43e423a59.tar.gz
podman-0d2b5532c417c58bd24e71a56c5c55b43e423a59.tar.bz2
podman-0d2b5532c417c58bd24e71a56c5c55b43e423a59.zip
Merge pull request #5852 from baude/v1prune
Podman V2 birth
Diffstat (limited to 'cmd/podman/import.go')
-rw-r--r--cmd/podman/import.go88
1 files changed, 0 insertions, 88 deletions
diff --git a/cmd/podman/import.go b/cmd/podman/import.go
deleted file mode 100644
index 5a21e5cc1..000000000
--- a/cmd/podman/import.go
+++ /dev/null
@@ -1,88 +0,0 @@
-package main
-
-import (
- "fmt"
-
- "github.com/containers/libpod/cmd/podman/cliconfig"
- "github.com/containers/libpod/cmd/podman/shared/parse"
- "github.com/containers/libpod/pkg/adapter"
- "github.com/hashicorp/go-multierror"
- "github.com/pkg/errors"
- "github.com/spf13/cobra"
-)
-
-var (
- 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 = &cobra.Command{
- Use: "import [flags] PATH [REFERENCE]",
- 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
- importCommand.Remote = remoteclient
- return importCmd(&importCommand)
- },
- Example: `podman import http://example.com/ctr.tar url-image
- cat ctr.tar | podman -q import --message "importing the ctr.tar tarball" - image-imported
- cat ctr.tar | podman import -`,
- }
-)
-
-func init() {
- importCommand.Command = _importCommand
- importCommand.SetHelpTemplate(HelpTemplate())
- importCommand.SetUsageTemplate(UsageTemplate())
- flags := importCommand.Flags()
- flags.StringArrayVarP(&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")
-
-}
-
-func importCmd(c *cliconfig.ImportValues) error {
- runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand)
- if err != nil {
- return errors.Wrapf(err, "could not get runtime")
- }
- defer runtime.DeferredShutdown(false)
-
- var (
- source string
- reference string
- )
- 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")
- case 1:
- source = args[0]
- case 2:
- source = args[0]
- reference = args[1]
- default:
- return errors.Errorf("too many arguments. Usage TARBALL [REFERENCE]")
- }
-
- errFileName := parse.ValidateFileName(source)
- errURL := parse.ValidURL(source)
-
- if errFileName != nil && errURL != nil {
- return multierror.Append(errFileName, errURL)
- }
-
- quiet := c.Quiet
- if runtime.Remote {
- quiet = false
- }
- iid, err := runtime.Import(getContext(), source, reference, importCommand.Change, c.String("message"), quiet)
- if err == nil {
- fmt.Println(iid)
- }
- return err
-}