Skip to content

Commit

Permalink
Merge pull request containers#12153 from flouthoc/allow-tagging-manif…
Browse files Browse the repository at this point in the history
…est-list-3.4

[backport] tag: Support tagging manifest list instead of resolving to images.
  • Loading branch information
openshift-merge-robot authored Nov 1, 2021
2 parents 09aade7 + 5c2d17e commit 75023e9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
5 changes: 4 additions & 1 deletion pkg/api/handlers/compat/images_tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"net/http"

"github.com/containers/common/libimage"
"github.com/containers/podman/v3/libpod"
"github.com/containers/podman/v3/pkg/api/handlers/utils"
api "github.com/containers/podman/v3/pkg/api/types"
Expand All @@ -16,7 +17,9 @@ func TagImage(w http.ResponseWriter, r *http.Request) {
// /v1.xx/images/(name)/tag
name := utils.GetName(r)

newImage, _, err := runtime.LibimageRuntime().LookupImage(name, nil)
// Allow tagging manifest list instead of resolving instances from manifest
lookupOptions := &libimage.LookupImageOptions{ManifestList: true}
newImage, _, err := runtime.LibimageRuntime().LookupImage(name, lookupOptions)
if err != nil {
utils.ImageNotFound(w, name, errors.Wrapf(err, "failed to find image %s", name))
return
Expand Down
4 changes: 3 additions & 1 deletion pkg/domain/infra/abi/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,9 @@ func (ir *ImageEngine) Push(ctx context.Context, source string, destination stri
}

func (ir *ImageEngine) Tag(ctx context.Context, nameOrID string, tags []string, options entities.ImageTagOptions) error {
image, _, err := ir.Libpod.LibimageRuntime().LookupImage(nameOrID, nil)
// Allow tagging manifest list instead of resolving instances from manifest
lookupOptions := &libimage.LookupImageOptions{ManifestList: true}
image, _, err := ir.Libpod.LibimageRuntime().LookupImage(nameOrID, lookupOptions)
if err != nil {
return err
}
Expand Down
19 changes: 19 additions & 0 deletions test/e2e/manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,25 @@ var _ = Describe("Podman manifest", func() {
Expect(session.OutputToString()).To(ContainSubstring(imageListARM64InstanceDigest))
})

It("podman manifest tag", func() {
session := podmanTest.Podman([]string{"manifest", "create", "foobar"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
session = podmanTest.Podman([]string{"manifest", "add", "foobar", "quay.io/libpod/busybox"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
session = podmanTest.Podman([]string{"tag", "foobar", "foobar2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
session = podmanTest.Podman([]string{"manifest", "inspect", "foobar"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
session2 := podmanTest.Podman([]string{"manifest", "inspect", "foobar2"})
session2.WaitWithDefaultTimeout()
Expect(session2).Should(Exit(0))
Expect(session2.OutputToString()).To(Equal(session.OutputToString()))
})

It("podman manifest add --all", func() {
session := podmanTest.Podman([]string{"manifest", "create", "foo"})
session.WaitWithDefaultTimeout()
Expand Down

0 comments on commit 75023e9

Please sign in to comment.