mirror of
https://github.com/containers/podman.git
synced 2025-06-23 10:38:20 +08:00
Merge pull request #8039 from zhangguanzhang/runlabel-panic
Fix panic when runlabel is missing
This commit is contained in:
@ -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 {
|
||||
|
@ -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() {
|
||||
|
Reference in New Issue
Block a user