summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pkg/domain/infra/abi/containers_runlabel.go3
-rw-r--r--test/e2e/runlabel_test.go5
2 files changed, 7 insertions, 1 deletions
diff --git a/pkg/domain/infra/abi/containers_runlabel.go b/pkg/domain/infra/abi/containers_runlabel.go
index 30a5a55b8..41fdf8f34 100644
--- a/pkg/domain/infra/abi/containers_runlabel.go
+++ b/pkg/domain/infra/abi/containers_runlabel.go
@@ -28,6 +28,9 @@ func (ic *ContainerEngine) ContainerRunlabel(ctx context.Context, label string,
if err != nil {
return err
}
+ if runlabel == "" {
+ return errors.Errorf("cannot find the value of label: %s in image: %s", label, imageRef)
+ }
cmd, env, err := generateRunlabelCommand(runlabel, img, args, options)
if err != nil {
diff --git a/test/e2e/runlabel_test.go b/test/e2e/runlabel_test.go
index 81a746b86..7c0b8bc9b 100644
--- a/test/e2e/runlabel_test.go
+++ b/test/e2e/runlabel_test.go
@@ -88,12 +88,15 @@ var _ = Describe("podman container runlabel", func() {
result := podmanTest.Podman([]string{"container", "runlabel", "RUN", ALPINE})
result.WaitWithDefaultTimeout()
Expect(result).To(ExitWithError())
+ // should not panic when label missing the value or don't have the label
+ Expect(result.LineInOutputContains("panic")).NotTo(BeTrue())
})
It("podman container runlabel bogus label in remote image should result in non-zero exit", func() {
result := podmanTest.Podman([]string{"container", "runlabel", "RUN", "docker.io/library/ubuntu:latest"})
result.WaitWithDefaultTimeout()
Expect(result).To(ExitWithError())
-
+ // should not panic when label missing the value or don't have the label
+ Expect(result.LineInOutputContains("panic")).NotTo(BeTrue())
})
It("podman container runlabel global options", func() {