github.com/containers/podman/v5@v5.1.0-rc1/test/e2e/runlabel_test.go (about) 1 package integration 2 3 import ( 4 "fmt" 5 6 . "github.com/containers/podman/v5/test/utils" 7 . "github.com/onsi/ginkgo/v2" 8 . "github.com/onsi/gomega" 9 ) 10 11 var PodmanDockerfile = fmt.Sprintf(` 12 FROM %s 13 LABEL RUN podman --version`, ALPINE) 14 15 var LsDockerfile = fmt.Sprintf(` 16 FROM %s 17 LABEL RUN ls -la`, ALPINE) 18 19 var PodmanRunlabelNameDockerfile = fmt.Sprintf(` 20 FROM %s 21 LABEL RUN podman run --name NAME IMAGE`, ALPINE) 22 23 var _ = Describe("podman container runlabel", func() { 24 25 BeforeEach(func() { 26 SkipIfRemote("runlabel is not supported for remote connections") 27 }) 28 29 It("podman container runlabel (podman --version)", func() { 30 image := "podman-runlabel-test:podman" 31 podmanTest.BuildImage(PodmanDockerfile, image, "false") 32 33 result := podmanTest.Podman([]string{"container", "runlabel", "RUN", image}) 34 result.WaitWithDefaultTimeout() 35 Expect(result).Should(ExitCleanly()) 36 37 result = podmanTest.Podman([]string{"rmi", image}) 38 result.WaitWithDefaultTimeout() 39 Expect(result).Should(ExitCleanly()) 40 }) 41 42 It("podman container runlabel (ls -la)", func() { 43 image := "podman-runlabel-test:ls" 44 podmanTest.BuildImage(LsDockerfile, image, "false") 45 46 result := podmanTest.Podman([]string{"container", "runlabel", "RUN", image}) 47 result.WaitWithDefaultTimeout() 48 Expect(result).Should(ExitCleanly()) 49 50 result = podmanTest.Podman([]string{"rmi", image}) 51 result.WaitWithDefaultTimeout() 52 Expect(result).Should(ExitCleanly()) 53 }) 54 It("podman container runlabel --display", func() { 55 image := "podman-runlabel-test:ls" 56 podmanTest.BuildImage(LsDockerfile, image, "false") 57 58 result := podmanTest.Podman([]string{"container", "runlabel", "--display", "RUN", image}) 59 result.WaitWithDefaultTimeout() 60 Expect(result).Should(ExitCleanly()) 61 Expect(result.OutputToString()).To(ContainSubstring(podmanTest.PodmanBinary + " -la")) 62 63 result = podmanTest.Podman([]string{"rmi", image}) 64 result.WaitWithDefaultTimeout() 65 Expect(result).Should(ExitCleanly()) 66 }) 67 68 It("podman container runlabel bogus label should result in non-zero exit code", func() { 69 result := podmanTest.Podman([]string{"container", "runlabel", "RUN", ALPINE}) 70 result.WaitWithDefaultTimeout() 71 Expect(result).To(ExitWithError(125, fmt.Sprintf("cannot find the value of label: RUN in image: %s", ALPINE))) 72 // should not panic when label missing the value or don't have the label 73 Expect(result.OutputToString()).To(Not(ContainSubstring("panic"))) 74 }) 75 76 It("podman container runlabel bogus label in remote image should result in non-zero exit", func() { 77 remoteImage := "quay.io/libpod/testimage:00000000" 78 result := podmanTest.Podman([]string{"container", "runlabel", "RUN", remoteImage}) 79 result.WaitWithDefaultTimeout() 80 Expect(result).To(ExitWithError(125, fmt.Sprintf("cannot find the value of label: RUN in image: %s", remoteImage))) 81 // should not panic when label missing the value or don't have the label 82 Expect(result.OutputToString()).To(Not(ContainSubstring("panic"))) 83 }) 84 85 It("runlabel should fail with nonexistent authfile", func() { 86 image := "podman-runlabel-test:podman" 87 podmanTest.BuildImage(PodmanDockerfile, image, "false") 88 89 // runlabel should fail with nonexistent authfile 90 result := podmanTest.Podman([]string{"container", "runlabel", "--authfile", "/tmp/nonexistent", "RUN", image}) 91 result.WaitWithDefaultTimeout() 92 Expect(result).To(ExitWithError(125, "credential file is not accessible: faccessat /tmp/nonexistent: no such file or directory")) 93 94 result = podmanTest.Podman([]string{"rmi", image}) 95 result.WaitWithDefaultTimeout() 96 Expect(result).Should(ExitCleanly()) 97 }) 98 99 It("podman container runlabel name removes tag from image", func() { 100 image := "podman-runlabel-name:sometag" 101 podmanTest.BuildImage(PodmanRunlabelNameDockerfile, image, "false") 102 103 result := podmanTest.Podman([]string{"container", "runlabel", "--display", "RUN", image}) 104 result.WaitWithDefaultTimeout() 105 Expect(result).Should(ExitCleanly()) 106 Expect(result.OutputToString()).To(Equal("command: " + podmanTest.PodmanBinary + " run --name podman-runlabel-name localhost/" + image)) 107 108 result = podmanTest.Podman([]string{"rmi", image}) 109 result.WaitWithDefaultTimeout() 110 Expect(result).Should(ExitCleanly()) 111 }) 112 })