6
. "github.com/containers/podman/v5/test/utils"
7
. "github.com/onsi/ginkgo/v2"
8
. "github.com/onsi/gomega"
11
var PodmanDockerfile = fmt.Sprintf(`
13
LABEL RUN podman --version`, ALPINE)
15
var LsDockerfile = fmt.Sprintf(`
17
LABEL RUN ls -la`, ALPINE)
19
var PodmanRunlabelNameDockerfile = fmt.Sprintf(`
21
LABEL RUN podman run --name NAME IMAGE`, ALPINE)
23
var _ = Describe("podman container runlabel", func() {
26
SkipIfRemote("runlabel is not supported for remote connections")
29
It("podman container runlabel (podman --version)", func() {
30
image := "podman-runlabel-test:podman"
31
podmanTest.BuildImage(PodmanDockerfile, image, "false")
33
result := podmanTest.Podman([]string{"container", "runlabel", "RUN", image})
34
result.WaitWithDefaultTimeout()
35
Expect(result).Should(ExitCleanly())
37
result = podmanTest.Podman([]string{"rmi", image})
38
result.WaitWithDefaultTimeout()
39
Expect(result).Should(ExitCleanly())
42
It("podman container runlabel (ls -la)", func() {
43
image := "podman-runlabel-test:ls"
44
podmanTest.BuildImage(LsDockerfile, image, "false")
46
result := podmanTest.Podman([]string{"container", "runlabel", "RUN", image})
47
result.WaitWithDefaultTimeout()
48
Expect(result).Should(ExitCleanly())
50
result = podmanTest.Podman([]string{"rmi", image})
51
result.WaitWithDefaultTimeout()
52
Expect(result).Should(ExitCleanly())
54
It("podman container runlabel --display", func() {
55
image := "podman-runlabel-test:ls"
56
podmanTest.BuildImage(LsDockerfile, image, "false")
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"))
63
result = podmanTest.Podman([]string{"rmi", image})
64
result.WaitWithDefaultTimeout()
65
Expect(result).Should(ExitCleanly())
67
It("podman container runlabel bogus label should result in non-zero exit code", func() {
68
result := podmanTest.Podman([]string{"container", "runlabel", "RUN", ALPINE})
69
result.WaitWithDefaultTimeout()
70
Expect(result).To(ExitWithError())
72
Expect(result.OutputToString()).To(Not(ContainSubstring("panic")))
74
It("podman container runlabel bogus label in remote image should result in non-zero exit", func() {
75
result := podmanTest.Podman([]string{"container", "runlabel", "RUN", "docker.io/library/ubuntu:latest"})
76
result.WaitWithDefaultTimeout()
77
Expect(result).To(ExitWithError())
79
Expect(result.OutputToString()).To(Not(ContainSubstring("panic")))
82
It("runlabel should fail with nonexistent authfile", func() {
83
image := "podman-runlabel-test:podman"
84
podmanTest.BuildImage(PodmanDockerfile, image, "false")
87
result := podmanTest.Podman([]string{"container", "runlabel", "--authfile", "/tmp/nonexistent", "RUN", image})
88
result.WaitWithDefaultTimeout()
89
Expect(result).To(ExitWithError())
91
result = podmanTest.Podman([]string{"rmi", image})
92
result.WaitWithDefaultTimeout()
93
Expect(result).Should(ExitCleanly())
96
It("podman container runlabel name removes tag from image", func() {
97
image := "podman-runlabel-name:sometag"
98
podmanTest.BuildImage(PodmanRunlabelNameDockerfile, image, "false")
100
result := podmanTest.Podman([]string{"container", "runlabel", "--display", "RUN", image})
101
result.WaitWithDefaultTimeout()
102
Expect(result).Should(ExitCleanly())
103
Expect(result.OutputToString()).To(Equal("command: " + podmanTest.PodmanBinary + " run --name podman-runlabel-name localhost/" + image))
105
result = podmanTest.Podman([]string{"rmi", image})
106
result.WaitWithDefaultTimeout()
107
Expect(result).Should(ExitCleanly())