summaryrefslogtreecommitdiff
path: root/cmd/podman/load.go
diff options
context:
space:
mode:
authorumohnani8 <umohnani@redhat.com>2018-05-21 13:53:19 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2018-05-25 15:15:47 +0000
commitc8b72e57a75262c0edeea839e9e34bb0c3e03d13 (patch)
tree3a2bb7210d309e358bfe84a0ab0f60e57b9f2e2f /cmd/podman/load.go
parent0a4ade1c175d3188ad55d22d751a86c96e060a44 (diff)
downloadpodman-c8b72e57a75262c0edeea839e9e34bb0c3e03d13.tar.gz
podman-c8b72e57a75262c0edeea839e9e34bb0c3e03d13.tar.bz2
podman-c8b72e57a75262c0edeea839e9e34bb0c3e03d13.zip
save and load should support multi-tag for docker-archive
The docker-archive tar files can have multiple tags for the same image stored in it. Load pulls all the tags found in the archive when loading a tar file. Save can oush multiple tags of the same image to a tar archive. Signed-off-by: umohnani8 <umohnani@redhat.com> Closes: #819 Approved by: rhatdan
Diffstat (limited to 'cmd/podman/load.go')
-rw-r--r--cmd/podman/load.go22
1 files changed, 17 insertions, 5 deletions
diff --git a/cmd/podman/load.go b/cmd/podman/load.go
index 2f66df7c8..ab3cc29b8 100644
--- a/cmd/podman/load.go
+++ b/cmd/podman/load.go
@@ -9,7 +9,7 @@ import (
"github.com/pkg/errors"
"github.com/projectatomic/libpod/cmd/podman/libpodruntime"
"github.com/projectatomic/libpod/libpod"
- libpodImage "github.com/projectatomic/libpod/libpod/image"
+ "github.com/projectatomic/libpod/libpod/image"
"github.com/urfave/cli"
)
@@ -105,22 +105,34 @@ func loadCmd(c *cli.Context) error {
ctx := getContext()
src := libpod.DockerArchive + ":" + input
- newImage, err := runtime.ImageRuntime().New(ctx, src, c.String("signature-policy"), "", writer, &libpodImage.DockerRegistryOptions{}, libpodImage.SigningOptions{}, false, false)
+ newImages, err := runtime.ImageRuntime().LoadFromArchive(ctx, src, c.String("signature-policy"), writer)
if err != nil {
// generate full src name with specified image:tag
fullSrc := libpod.OCIArchive + ":" + input
if image != "" {
fullSrc = fullSrc + ":" + image
}
- newImage, err = runtime.ImageRuntime().New(ctx, fullSrc, c.String("signature-policy"), "", writer, &libpodImage.DockerRegistryOptions{}, libpodImage.SigningOptions{}, false, false)
+ newImages, err = runtime.ImageRuntime().LoadFromArchive(ctx, fullSrc, c.String("signature-policy"), writer)
if err != nil {
src = libpod.DirTransport + ":" + input
- newImage, err = runtime.ImageRuntime().New(ctx, src, c.String("signature-policy"), "", writer, &libpodImage.DockerRegistryOptions{}, libpodImage.SigningOptions{}, false, false)
+ newImages, err = runtime.ImageRuntime().LoadFromArchive(ctx, src, c.String("signature-policy"), writer)
if err != nil {
return errors.Wrapf(err, "error pulling %q", src)
}
}
}
- fmt.Println("Loaded image: ", newImage.InputName)
+ fmt.Println("Loaded image(s): " + getImageNames(newImages))
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
+}