From e66c04c1f7ae7851d94b5991209dc0d9251e3446 Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Wed, 30 Aug 2023 10:58:54 +0200 Subject: [PATCH] vendor containers/common@12405381ff45 When pulling from an OCI source, make sure to preseve the optional name. For instance, a podman pull oci:/tmp/foo:quay.io/foo/bar:latest should pull the image and name it quay.io/foo/bar:latest. While at it, also fix a bug when pulling an OCI without the optional name. Previously, we used the path to name the image which will error in most cases due to invalid characters (e.g., capital ones). Hence, apply the same trick as for the dir transport and generate a sha. Signed-off-by: Valentin Rothberg --- go.mod | 2 +- go.sum | 4 ++-- test/e2e/load_test.go | 6 +----- test/e2e/pull_test.go | 11 ++++++----- .../github.com/containers/common/libimage/pull.go | 14 ++++++++++++-- vendor/modules.txt | 2 +- 6 files changed, 23 insertions(+), 16 deletions(-) diff --git a/go.mod b/go.mod index 1f6ce3e820..e002d13c55 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/containernetworking/cni v1.1.2 github.com/containernetworking/plugins v1.3.0 github.com/containers/buildah v1.31.1-0.20230722114901-5ece066f82c6 - github.com/containers/common v0.55.1-0.20230829104013-4a76f1739d43 + github.com/containers/common v0.55.1-0.20230830075933-12405381ff45 github.com/containers/conmon v2.0.20+incompatible github.com/containers/image/v5 v5.26.1-0.20230807184415-3fb422379cfa github.com/containers/libhvee v0.4.1-0.20230816135538-b81ee3f10e1e diff --git a/go.sum b/go.sum index 84f3a9ec2b..057668d13f 100644 --- a/go.sum +++ b/go.sum @@ -246,8 +246,8 @@ github.com/containernetworking/plugins v1.3.0 h1:QVNXMT6XloyMUoO2wUOqWTC1hWFV62Q github.com/containernetworking/plugins v1.3.0/go.mod h1:Pc2wcedTQQCVuROOOaLBPPxrEXqqXBFt3cZ+/yVg6l0= github.com/containers/buildah v1.31.1-0.20230722114901-5ece066f82c6 h1:K/S8SFQsnnNTF0Ws58SrBD9L0EuClzAG8Zp08d7+6AA= github.com/containers/buildah v1.31.1-0.20230722114901-5ece066f82c6/go.mod h1:0sptTFBBtSznLqoTh80DfvMOCNbdRsNRgVOKhBhrupA= -github.com/containers/common v0.55.1-0.20230829104013-4a76f1739d43 h1:Or7mn/haMXOsLC3FiwTCaHRCdez5TkqEJE+U+rSwTIo= -github.com/containers/common v0.55.1-0.20230829104013-4a76f1739d43/go.mod h1:Xcw3UosoUax8jn+MZoxL7LbEbfxKqhUNMZyhdd5s/vk= +github.com/containers/common v0.55.1-0.20230830075933-12405381ff45 h1:hwUrFFjPuaQLKDjaXTc3hDfZp2X89IWKx4rBQX0bUwc= +github.com/containers/common v0.55.1-0.20230830075933-12405381ff45/go.mod h1:Xcw3UosoUax8jn+MZoxL7LbEbfxKqhUNMZyhdd5s/vk= github.com/containers/conmon v2.0.20+incompatible h1:YbCVSFSCqFjjVwHTPINGdMX1F6JXHGTUje2ZYobNrkg= github.com/containers/conmon v2.0.20+incompatible/go.mod h1:hgwZ2mtuDrppv78a/cOBNiCm6O0UMWGx1mu7P00nu5I= github.com/containers/image/v5 v5.26.1-0.20230807184415-3fb422379cfa h1:wDfVQtc6ik2MvsUmu/YRSyBAE5YUxdjcEDtuT1q2KDo= diff --git a/test/e2e/load_test.go b/test/e2e/load_test.go index abca272883..00f4f2ab13 100644 --- a/test/e2e/load_test.go +++ b/test/e2e/load_test.go @@ -249,11 +249,7 @@ var _ = Describe("Podman load", func() { load := podmanTest.Podman([]string{"load", "-i", outfile}) load.WaitWithDefaultTimeout() Expect(load).Should(Exit(0)) - - result := podmanTest.Podman([]string{"images", "load:latest"}) - result.WaitWithDefaultTimeout() - Expect(result.OutputToString()).To(Not(ContainSubstring("docker"))) - Expect(result.OutputToString()).To(ContainSubstring("localhost")) + Expect(load.OutputToString()).To(ContainSubstring("Loaded image: sha256:")) }) It("podman load xz compressed image", func() { diff --git a/test/e2e/pull_test.go b/test/e2e/pull_test.go index 399c6e3a6a..20ea46ad14 100644 --- a/test/e2e/pull_test.go +++ b/test/e2e/pull_test.go @@ -418,7 +418,8 @@ var _ = Describe("Podman pull", func() { dirpath := filepath.Join(podmanTest.TempDir, "cirros") err = os.MkdirAll(dirpath, os.ModePerm) Expect(err).ToNot(HaveOccurred()) - imgPath := fmt.Sprintf("oci:%s", dirpath) + imgName := "localhost/name:tag" + imgPath := fmt.Sprintf("oci:%s:%s", dirpath, imgName) session := podmanTest.Podman([]string{"push", "cirros", imgPath}) session.WaitWithDefaultTimeout() @@ -429,10 +430,9 @@ var _ = Describe("Podman pull", func() { session = podmanTest.Podman([]string{"pull", imgPath}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - session = podmanTest.Podman([]string{"images"}) + session = podmanTest.Podman([]string{"image", "exists", imgName}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - Expect(session.LineInOutputContainsTag(filepath.Join("localhost", dirpath), "latest")).To(BeTrue()) }) It("podman pull + inspect from unqualified-search registry", func() { @@ -648,11 +648,12 @@ var _ = Describe("Podman pull", func() { podmanTest.AddImageToRWStore(ALPINE) bbdir := filepath.Join(podmanTest.TempDir, "busybox-oci") - imgPath := fmt.Sprintf("oci:%s", bbdir) + imgName := "localhost/name:tag" + imgPath := fmt.Sprintf("oci:%s:%s", bbdir, imgName) session := decryptionTestHelper(imgPath) - Expect(session.LineInOutputContainsTag(filepath.Join("localhost", bbdir), "latest")).To(BeTrue()) + Expect(session.LineInOutputContainsTag("localhost/name", "tag")).To(BeTrue()) }) It("From local registry", func() { diff --git a/vendor/github.com/containers/common/libimage/pull.go b/vendor/github.com/containers/common/libimage/pull.go index 1e8cc42c2d..bdf172d17b 100644 --- a/vendor/github.com/containers/common/libimage/pull.go +++ b/vendor/github.com/containers/common/libimage/pull.go @@ -230,8 +230,18 @@ func (r *Runtime) copyFromDefault(ctx context.Context, ref types.ImageReference, case ociTransport.Transport.Name(): split := strings.SplitN(ref.StringWithinTransport(), ":", 2) - storageName = toLocalImageName(split[0]) - imageName = storageName + if len(split) == 1 || split[1] == "" { + // Same trick as for the dir transport: we cannot use + // the path to a directory as the name. + storageName, err = getImageID(ctx, ref, nil) + if err != nil { + return nil, err + } + imageName = "sha256:" + storageName[1:] + } else { // If the OCI-reference includes an image reference, use it + storageName = split[1] + imageName = storageName + } case ociArchiveTransport.Transport.Name(): manifestDescriptor, err := ociArchiveTransport.LoadManifestDescriptorWithContext(r.SystemContext(), ref) diff --git a/vendor/modules.txt b/vendor/modules.txt index 3de158a0ec..2357910a2e 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -156,7 +156,7 @@ github.com/containers/buildah/pkg/rusage github.com/containers/buildah/pkg/sshagent github.com/containers/buildah/pkg/util github.com/containers/buildah/util -# github.com/containers/common v0.55.1-0.20230829104013-4a76f1739d43 +# github.com/containers/common v0.55.1-0.20230830075933-12405381ff45 ## explicit; go 1.18 github.com/containers/common/libimage github.com/containers/common/libimage/define