mirror of
https://github.com/containers/podman.git
synced 2025-06-23 02:18:13 +08:00
Make invalid image name error more specific
Previously, using an invalid image name would produce an error like this: Error: error encountered while bringing up pod test-pod-0: invalid reference format This message didn't specify that there was an problem with an image name, and it didn't specify which image name had a problem if there were multiple. Now the error reads: Error: error encountered while bringing up pod test-pod-0: Failed to parse image "./myimage": invalid reference format Signed-off-by: Jordan Christiansen <xordspar0@gmail.com>
This commit is contained in:
@ -341,7 +341,7 @@ func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podY
|
|||||||
}
|
}
|
||||||
named, err := reference.ParseNormalizedNamed(container.Image)
|
named, err := reference.ParseNormalizedNamed(container.Image)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, errors.Wrapf(err, "Failed to parse image %q", container.Image)
|
||||||
}
|
}
|
||||||
// In kube, if the image is tagged with latest, it should always pull
|
// In kube, if the image is tagged with latest, it should always pull
|
||||||
if tagged, isTagged := named.(reference.NamedTagged); isTagged {
|
if tagged, isTagged := named.(reference.NamedTagged); isTagged {
|
||||||
|
@ -1447,4 +1447,23 @@ MemoryReservation: {{ .HostConfig.MemoryReservation }}`})
|
|||||||
Expect(inspect.OutputToString()).To(ContainSubstring("Memory: " + expectedMemoryLimit))
|
Expect(inspect.OutputToString()).To(ContainSubstring("Memory: " + expectedMemoryLimit))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman play kube reports invalid image name", func() {
|
||||||
|
invalidImageName := "./myimage"
|
||||||
|
|
||||||
|
pod := getPod(
|
||||||
|
withCtr(
|
||||||
|
getCtr(
|
||||||
|
withImage(invalidImageName),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
err := generateKubeYaml("pod", pod, kubeYaml)
|
||||||
|
Expect(err).To(BeNil())
|
||||||
|
|
||||||
|
kube := podmanTest.Podman([]string{"play", "kube", kubeYaml})
|
||||||
|
kube.WaitWithDefaultTimeout()
|
||||||
|
Expect(kube.ExitCode()).To(Equal(125))
|
||||||
|
Expect(kube.ErrorToString()).To(ContainSubstring(invalidImageName))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user