summaryrefslogtreecommitdiff
path: root/cmd/podman/pull.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/pull.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/pull.go')
-rw-r--r--cmd/podman/pull.go28
1 files changed, 21 insertions, 7 deletions
diff --git a/cmd/podman/pull.go b/cmd/podman/pull.go
index 521492dc5..a1e99fce2 100644
--- a/cmd/podman/pull.go
+++ b/cmd/podman/pull.go
@@ -1,14 +1,15 @@
package main
import (
+ "fmt"
"io"
"os"
-
- "fmt"
+ "strings"
"github.com/containers/image/types"
"github.com/pkg/errors"
"github.com/projectatomic/libpod/cmd/podman/libpodruntime"
+ "github.com/projectatomic/libpod/libpod"
image2 "github.com/projectatomic/libpod/libpod/image"
"github.com/projectatomic/libpod/pkg/util"
"github.com/sirupsen/logrus"
@@ -90,7 +91,10 @@ func pullCmd(c *cli.Context) error {
registryCreds = creds
}
- var writer io.Writer
+ var (
+ writer io.Writer
+ imgID string
+ )
if !c.Bool("quiet") {
writer = os.Stderr
}
@@ -104,13 +108,23 @@ func pullCmd(c *cli.Context) error {
forceSecure = c.Bool("tls-verify")
}
- newImage, err := runtime.ImageRuntime().New(getContext(), image, c.String("signature-policy"), c.String("authfile"), writer, &dockerRegistryOptions, image2.SigningOptions{}, true, forceSecure)
- if err != nil {
- return errors.Wrapf(err, "error pulling image %q", image)
+ // Possible for docker-archive to have multiple tags, so use NewFromLoad instead
+ if strings.Contains(image, libpod.DockerArchive) {
+ newImage, err := runtime.ImageRuntime().LoadFromArchive(getContext(), image, c.String("signature-policy"), writer)
+ if err != nil {
+ return errors.Wrapf(err, "error pulling image from %q", image)
+ }
+ imgID = newImage[0].ID()
+ } else {
+ newImage, err := runtime.ImageRuntime().New(getContext(), image, c.String("signature-policy"), c.String("authfile"), writer, &dockerRegistryOptions, image2.SigningOptions{}, true, forceSecure)
+ if err != nil {
+ return errors.Wrapf(err, "error pulling image %q", image)
+ }
+ imgID = newImage.ID()
}
// Intentionally choosing to ignore if there is an error because
// outputting the image ID is a NTH and not integral to the pull
- fmt.Println(newImage.ID())
+ fmt.Println(imgID)
return nil
}