diff options
author | umohnani8 <umohnani@redhat.com> | 2018-05-21 13:53:19 -0400 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-05-25 15:15:47 +0000 |
commit | c8b72e57a75262c0edeea839e9e34bb0c3e03d13 (patch) | |
tree | 3a2bb7210d309e358bfe84a0ab0f60e57b9f2e2f /cmd/podman/save.go | |
parent | 0a4ade1c175d3188ad55d22d751a86c96e060a44 (diff) | |
download | podman-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/save.go')
-rw-r--r-- | cmd/podman/save.go | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/cmd/podman/save.go b/cmd/podman/save.go index 32ac37f89..2f9adc843 100644 --- a/cmd/podman/save.go +++ b/cmd/podman/save.go @@ -5,6 +5,7 @@ import ( "os" "strings" + "github.com/containers/image/docker/reference" "github.com/containers/image/manifest" imgspecv1 "github.com/opencontainers/image-spec/specs-go/v1" "github.com/pkg/errors" @@ -109,24 +110,29 @@ func saveCmd(c *cli.Context) error { return errors.Errorf("unknown format option %q", c.String("format")) } - // only one image is supported for now - // future pull requests will fix this - for _, image := range args { - newImage, err := runtime.ImageRuntime().NewFromLocal(image) + // supports saving multiple tags to the same tar archive + var additionaltags []reference.NamedTagged + if len(args) > 1 { + additionaltags, err = libpodImage.GetAdditionalTags(args[1:]) if err != nil { return err } - dest := dst - // need dest to be in the format transport:path:reference for the following transports - if (strings.Contains(dst, libpod.OCIArchive) || strings.Contains(dst, libpod.DockerArchive)) && !strings.Contains(newImage.ID(), image) { - dest = dst + ":" + image - } - if err := newImage.PushImage(getContext(), dest, manifestType, "", "", writer, c.Bool("compress"), libpodImage.SigningOptions{}, &libpodImage.DockerRegistryOptions{}, false); err != nil { - if err2 := os.Remove(output); err2 != nil { - logrus.Errorf("error deleting %q: %v", output, err) - } - return errors.Wrapf(err, "unable to save %q", image) + } + newImage, err := runtime.ImageRuntime().NewFromLocal(args[0]) + if err != nil { + return err + } + dest := dst + // need dest to be in the format transport:path:reference for the following transports + if (strings.Contains(dst, libpod.OCIArchive) || strings.Contains(dst, libpod.DockerArchive)) && !strings.Contains(newImage.ID(), args[0]) { + dest = dst + ":" + args[0] + } + if err := newImage.PushImage(getContext(), dest, manifestType, "", "", writer, c.Bool("compress"), libpodImage.SigningOptions{}, &libpodImage.DockerRegistryOptions{}, false, additionaltags); err != nil { + if err2 := os.Remove(output); err2 != nil { + logrus.Errorf("error deleting %q: %v", output, err) } + return errors.Wrapf(err, "unable to save %q", args) } + return nil } |