summaryrefslogtreecommitdiff
path: root/cmd/podman/load.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2019-02-19 13:36:42 -0600
committerbaude <bbaude@redhat.com>2019-02-21 10:11:19 -0600
commit71db80ddb15addb4197693bc056c35dd8ff0d6ac (patch)
tree9b3614c1c806dca4bf4745448d9e57c82d6fe2d3 /cmd/podman/load.go
parentaf922fb2c6baceb89cc8e4acd6d84a6474b32dda (diff)
downloadpodman-71db80ddb15addb4197693bc056c35dd8ff0d6ac.tar.gz
podman-71db80ddb15addb4197693bc056c35dd8ff0d6ac.tar.bz2
podman-71db80ddb15addb4197693bc056c35dd8ff0d6ac.zip
podman-remote load image
enable the ability to load an image into remote storage using the remote client. Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'cmd/podman/load.go')
-rw-r--r--cmd/podman/load.go54
1 files changed, 8 insertions, 46 deletions
diff --git a/cmd/podman/load.go b/cmd/podman/load.go
index 34a51cd0d..514c9f1e9 100644
--- a/cmd/podman/load.go
+++ b/cmd/podman/load.go
@@ -6,12 +6,8 @@ import (
"io/ioutil"
"os"
- "github.com/containers/image/directory"
- dockerarchive "github.com/containers/image/docker/archive"
- ociarchive "github.com/containers/image/oci/archive"
"github.com/containers/libpod/cmd/podman/cliconfig"
- "github.com/containers/libpod/cmd/podman/libpodruntime"
- "github.com/containers/libpod/libpod/image"
+ "github.com/containers/libpod/libpod/adapter"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
@@ -56,14 +52,16 @@ func loadCmd(c *cliconfig.LoadValues) error {
return errors.New("too many arguments. Requires exactly 1")
}
- runtime, err := libpodruntime.GetRuntime(&c.PodmanCommand)
+ runtime, err := adapter.GetRuntime(&c.PodmanCommand)
if err != nil {
return errors.Wrapf(err, "could not get runtime")
}
defer runtime.Shutdown(false)
input := c.Input
-
+ if runtime.Remote && len(input) == 0 {
+ return errors.New("the remote client requires you to load via -i and a tarball")
+ }
if input == "/dev/stdin" {
fi, err := os.Stdin.Stat()
if err != nil {
@@ -96,46 +94,10 @@ func loadCmd(c *cliconfig.LoadValues) error {
return err
}
- var writer io.Writer
- if !c.Quiet {
- writer = os.Stderr
- }
-
- ctx := getContext()
-
- var newImages []*image.Image
- src, err := dockerarchive.ParseReference(input) // FIXME? We should add dockerarchive.NewReference()
- if err == nil {
- newImages, err = runtime.ImageRuntime().LoadFromArchiveReference(ctx, src, c.SignaturePolicy, writer)
- }
+ names, err := runtime.LoadImage(getContext(), imageName, c)
if err != nil {
- // generate full src name with specified image:tag
- src, err := ociarchive.NewReference(input, imageName) // imageName may be ""
- if err == nil {
- newImages, err = runtime.ImageRuntime().LoadFromArchiveReference(ctx, src, c.SignaturePolicy, writer)
- }
- if err != nil {
- src, err := directory.NewReference(input)
- if err == nil {
- newImages, err = runtime.ImageRuntime().LoadFromArchiveReference(ctx, src, c.SignaturePolicy, writer)
- }
- if err != nil {
- return errors.Wrapf(err, "error pulling %q", input)
- }
- }
+ return err
}
- fmt.Println("Loaded image(s): " + getImageNames(newImages))
+ fmt.Println("Loaded image(s): " + names)
return nil
}
-
-func getImageNames(images []*image.Image) string {
- var names string
- for i := range images {
- if i == 0 {
- names = images[i].InputName
- } else {
- names += ", " + images[i].InputName
- }
- }
- return names
-}