summaryrefslogtreecommitdiff
path: root/libpod/image/image.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 /libpod/image/image.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 'libpod/image/image.go')
-rw-r--r--libpod/image/image.go43
1 files changed, 39 insertions, 4 deletions
diff --git a/libpod/image/image.go b/libpod/image/image.go
index b7d9200ec..c8a929074 100644
--- a/libpod/image/image.go
+++ b/libpod/image/image.go
@@ -147,7 +147,7 @@ func (ir *Runtime) New(ctx context.Context, name, signaturePolicyPath, authfile
return nil, errors.Wrapf(err, "unable to pull %s", name)
}
- newImage.InputName = imageName
+ newImage.InputName = imageName[0]
img, err := newImage.getLocalImage()
if err != nil {
return nil, errors.Wrapf(err, "error retrieving local image after pulling %s", name)
@@ -156,6 +156,41 @@ func (ir *Runtime) New(ctx context.Context, name, signaturePolicyPath, authfile
return &newImage, nil
}
+// LoadFromArchive creates a new image object for images pulled from a tar archive (podman load)
+// This function is needed because it is possible for a tar archive to have multiple tags for one image
+func (ir *Runtime) LoadFromArchive(ctx context.Context, name, signaturePolicyPath string, writer io.Writer) ([]*Image, error) {
+ var newImages []*Image
+ newImage := Image{
+ InputName: name,
+ Local: false,
+ imageruntime: ir,
+ }
+
+ if signaturePolicyPath == "" {
+ signaturePolicyPath = ir.SignaturePolicyPath
+ }
+ imageNames, err := newImage.pullImage(ctx, writer, "", signaturePolicyPath, SigningOptions{}, &DockerRegistryOptions{}, false)
+ if err != nil {
+ return nil, errors.Wrapf(err, "unable to pull %s", name)
+ }
+
+ for _, name := range imageNames {
+ newImage := Image{
+ InputName: name,
+ Local: true,
+ imageruntime: ir,
+ }
+ img, err := newImage.getLocalImage()
+ if err != nil {
+ return nil, errors.Wrapf(err, "error retrieving local image after pulling %s", name)
+ }
+ newImage.image = img
+ newImages = append(newImages, &newImage)
+ }
+
+ return newImages, nil
+}
+
// Shutdown closes down the storage and require a bool arg as to
// whether it should do so forcibly.
func (ir *Runtime) Shutdown(force bool) error {
@@ -428,7 +463,7 @@ func (i *Image) UntagImage(tag string) error {
}
// PushImage pushes the given image to a location described by the given path
-func (i *Image) PushImage(ctx context.Context, destination, manifestMIMEType, authFile, signaturePolicyPath string, writer io.Writer, forceCompress bool, signingOptions SigningOptions, dockerRegistryOptions *DockerRegistryOptions, forceSecure bool) error {
+func (i *Image) PushImage(ctx context.Context, destination, manifestMIMEType, authFile, signaturePolicyPath string, writer io.Writer, forceCompress bool, signingOptions SigningOptions, dockerRegistryOptions *DockerRegistryOptions, forceSecure bool, additionalDockerArchiveTags []reference.NamedTagged) error {
if destination == "" {
return errors.Wrapf(syscall.EINVAL, "destination image name must be specified")
}
@@ -464,7 +499,7 @@ func (i *Image) PushImage(ctx context.Context, destination, manifestMIMEType, au
if err != nil {
return err
}
- copyOptions := getCopyOptions(writer, signaturePolicyPath, nil, dockerRegistryOptions, signingOptions, authFile, manifestMIMEType, forceCompress)
+ copyOptions := getCopyOptions(writer, signaturePolicyPath, nil, dockerRegistryOptions, signingOptions, authFile, manifestMIMEType, forceCompress, additionalDockerArchiveTags)
if strings.HasPrefix(DockerTransport, dest.Transport().Name()) {
imgRef, err := reference.Parse(dest.DockerReference().String())
if err != nil {
@@ -749,7 +784,7 @@ func (ir *Runtime) Import(ctx context.Context, path, reference string, writer io
return nil, err
}
defer policyContext.Destroy()
- copyOptions := getCopyOptions(writer, "", nil, nil, signingOptions, "", "", false)
+ copyOptions := getCopyOptions(writer, "", nil, nil, signingOptions, "", "", false, nil)
dest, err := is.Transport.ParseStoreReference(ir.store, reference)
if err != nil {
errors.Wrapf(err, "error getting image reference for %q", reference)