mirror of
https://github.com/containers/podman.git
synced 2025-06-17 15:08:08 +08:00

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>
220 lines
7.6 KiB
Go
220 lines
7.6 KiB
Go
// +build !remoteclient
|
|
|
|
package integration
|
|
|
|
import (
|
|
"os"
|
|
|
|
"fmt"
|
|
"path/filepath"
|
|
"strings"
|
|
|
|
. "github.com/containers/libpod/test/utils"
|
|
. "github.com/onsi/ginkgo"
|
|
. "github.com/onsi/gomega"
|
|
)
|
|
|
|
var _ = Describe("Podman pull", func() {
|
|
var (
|
|
tempdir string
|
|
err error
|
|
podmanTest *PodmanTestIntegration
|
|
)
|
|
|
|
BeforeEach(func() {
|
|
tempdir, err = CreateTempDirInTempDir()
|
|
if err != nil {
|
|
os.Exit(1)
|
|
}
|
|
podmanTest = PodmanTestCreate(tempdir)
|
|
podmanTest.Setup()
|
|
})
|
|
|
|
AfterEach(func() {
|
|
podmanTest.Cleanup()
|
|
f := CurrentGinkgoTestDescription()
|
|
processTestResult(f)
|
|
|
|
})
|
|
|
|
It("podman pull from docker a not existing image", func() {
|
|
session := podmanTest.PodmanNoCache([]string{"pull", "ibetthisdoesntexistthere:foo"})
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session.ExitCode()).To(Not(Equal(0)))
|
|
})
|
|
|
|
It("podman pull from docker with tag", func() {
|
|
session := podmanTest.PodmanNoCache([]string{"pull", "busybox:glibc"})
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
session = podmanTest.PodmanNoCache([]string{"rmi", "busybox:glibc"})
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
})
|
|
|
|
It("podman pull from docker without tag", func() {
|
|
session := podmanTest.PodmanNoCache([]string{"pull", "busybox"})
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
session = podmanTest.PodmanNoCache([]string{"rmi", "busybox"})
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
})
|
|
|
|
It("podman pull from alternate registry with tag", func() {
|
|
session := podmanTest.PodmanNoCache([]string{"pull", nginx})
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
session = podmanTest.PodmanNoCache([]string{"rmi", nginx})
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
})
|
|
|
|
It("podman pull from alternate registry without tag", func() {
|
|
session := podmanTest.PodmanNoCache([]string{"pull", "quay.io/libpod/alpine_nginx"})
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
session = podmanTest.PodmanNoCache([]string{"rmi", "quay.io/libpod/alpine_nginx"})
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
})
|
|
|
|
It("podman pull by digest", func() {
|
|
session := podmanTest.PodmanNoCache([]string{"pull", "alpine@sha256:1072e499f3f655a032e88542330cf75b02e7bdf673278f701d7ba61629ee3ebe"})
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
session = podmanTest.PodmanNoCache([]string{"rmi", "alpine:none"})
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
})
|
|
|
|
It("podman pull bogus image", func() {
|
|
session := podmanTest.PodmanNoCache([]string{"pull", "umohnani/get-started"})
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session.ExitCode()).To(Not(Equal(0)))
|
|
})
|
|
|
|
It("podman pull from docker-archive", func() {
|
|
podmanTest.RestoreArtifact(ALPINE)
|
|
tarfn := filepath.Join(podmanTest.TempDir, "alp.tar")
|
|
session := podmanTest.PodmanNoCache([]string{"save", "-o", tarfn, "alpine"})
|
|
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", fmt.Sprintf("docker-archive:%s", tarfn)})
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
session = podmanTest.PodmanNoCache([]string{"rmi", "alpine"})
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
})
|
|
|
|
It("podman pull from oci-archive", func() {
|
|
podmanTest.RestoreArtifact(ALPINE)
|
|
tarfn := filepath.Join(podmanTest.TempDir, "oci-alp.tar")
|
|
session := podmanTest.PodmanNoCache([]string{"save", "--format", "oci-archive", "-o", tarfn, "alpine"})
|
|
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", fmt.Sprintf("oci-archive:%s", tarfn)})
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
session = podmanTest.PodmanNoCache([]string{"rmi", "alpine"})
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
})
|
|
|
|
It("podman pull from local directory", func() {
|
|
podmanTest.RestoreArtifact(ALPINE)
|
|
dirpath := filepath.Join(podmanTest.TempDir, "alpine")
|
|
os.MkdirAll(dirpath, os.ModePerm)
|
|
imgPath := fmt.Sprintf("dir:%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))
|
|
})
|
|
|
|
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))
|
|
})
|
|
|
|
It("podman pull check quiet", func() {
|
|
podmanTest.RestoreArtifact(ALPINE)
|
|
setup := podmanTest.PodmanNoCache([]string{"images", ALPINE, "-q", "--no-trunc"})
|
|
setup.WaitWithDefaultTimeout()
|
|
Expect(setup.ExitCode()).To(Equal(0))
|
|
shortImageId := strings.Split(setup.OutputToString(), ":")[1]
|
|
|
|
rmi := podmanTest.PodmanNoCache([]string{"rmi", ALPINE})
|
|
rmi.WaitWithDefaultTimeout()
|
|
Expect(rmi.ExitCode()).To(Equal(0))
|
|
|
|
pull := podmanTest.PodmanNoCache([]string{"pull", "-q", ALPINE})
|
|
pull.WaitWithDefaultTimeout()
|
|
Expect(pull.ExitCode()).To(Equal(0))
|
|
|
|
Expect(pull.OutputToString()).To(ContainSubstring(shortImageId))
|
|
})
|
|
|
|
It("podman pull check all tags", func() {
|
|
session := podmanTest.PodmanNoCache([]string{"pull", "--all-tags", "alpine"})
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
Expect(session.LineInOuputStartsWith("Pulled Images:")).To(BeTrue())
|
|
|
|
session = podmanTest.PodmanNoCache([]string{"images"})
|
|
session.WaitWithDefaultTimeout()
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 4))
|
|
|
|
rmi := podmanTest.PodmanNoCache([]string{"rmi", "-a", "-f"})
|
|
rmi.WaitWithDefaultTimeout()
|
|
Expect(rmi.ExitCode()).To(Equal(0))
|
|
})
|
|
})
|