Fix directory pull image name for OCI images

This is a breaking change and modifies the resulting image name when
pulling from an directory via `oci:...`.

Without this patch, the image names pulled via a local directory got
processed incorrectly, like this:

```
> podman pull oci:alpine
> podman images
REPOSITORY      TAG      IMAGE ID       CREATED       SIZE
localhost/oci   alpine   4fa153a82426   5 weeks ago   5.85 MB
```

We now use the same approach as in the corresponding [buildah fix][1] to
adapt the behavior for correct `localhost/` prefixing.

[1]: https://github.com/containers/buildah/pull/1800

After applying the patch the same OCI image pull looks like this:

```
> ./bin/podman pull oci:alpine
> podman images
REPOSITORY         TAG      IMAGE ID       CREATED       SIZE
localhost/alpine   latest   4fa153a82426   5 weeks ago   5.85 MB
```

End-to-end tests have been adapted as well to cover the added scenario.

Relates to: https://github.com/containers/buildah/issues/1797

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
This commit is contained in:
Sascha Grunert
2019-08-19 12:06:11 +02:00
parent 438cbf4c89
commit 22f55ce406
3 changed files with 48 additions and 7 deletions

View File

@ -150,6 +150,34 @@ var _ = Describe("Podman pull", func() {
session = podmanTest.PodmanNoCache([]string{"pull", imgPath})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
session = podmanTest.PodmanNoCache([]string{"images"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
Expect(session.LineInOutputContainsTag(filepath.Join("localhost", dirpath), "latest")).To(BeTrue())
session = podmanTest.PodmanNoCache([]string{"rmi", "alpine"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
})
It("podman pull from local OCI directory", func() {
podmanTest.RestoreArtifact(ALPINE)
dirpath := filepath.Join(podmanTest.TempDir, "alpine")
os.MkdirAll(dirpath, os.ModePerm)
imgPath := fmt.Sprintf("oci:%s", dirpath)
session := podmanTest.PodmanNoCache([]string{"push", "alpine", imgPath})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
session = podmanTest.PodmanNoCache([]string{"rmi", "alpine"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
session = podmanTest.PodmanNoCache([]string{"pull", imgPath})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
session = podmanTest.PodmanNoCache([]string{"images"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
Expect(session.LineInOutputContainsTag(filepath.Join("localhost", dirpath), "latest")).To(BeTrue())
session = podmanTest.PodmanNoCache([]string{"rmi", "alpine"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))