mirror of
https://github.com/containers/podman.git
synced 2025-06-20 17:13:43 +08:00
Merge pull request #12943 from machacekondra/nil_fix
Fix nil pointer dereference for configmap optional
This commit is contained in:
@ -122,7 +122,7 @@ func VolumeFromConfigMap(configMapVolumeSource *v1.ConfigMapVolumeSource, config
|
|||||||
|
|
||||||
if configMap == nil {
|
if configMap == nil {
|
||||||
// If the volumeSource was optional, move on even if a matching configmap wasn't found
|
// If the volumeSource was optional, move on even if a matching configmap wasn't found
|
||||||
if *configMapVolumeSource.Optional {
|
if configMapVolumeSource.Optional != nil && *configMapVolumeSource.Optional {
|
||||||
kv.Source = configMapVolumeSource.Name
|
kv.Source = configMapVolumeSource.Name
|
||||||
kv.Optional = *configMapVolumeSource.Optional
|
kv.Optional = *configMapVolumeSource.Optional
|
||||||
return kv, nil
|
return kv, nil
|
||||||
|
@ -78,6 +78,25 @@ spec:
|
|||||||
- 24h
|
- 24h
|
||||||
status: {}
|
status: {}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
var podWithoutConfigMapDefined = `
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Pod
|
||||||
|
metadata:
|
||||||
|
name: testpod1
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: alpine
|
||||||
|
image: quay.io/libpod/alpine:latest
|
||||||
|
volumeMounts:
|
||||||
|
- name: mycm
|
||||||
|
mountPath: /mycm
|
||||||
|
volumes:
|
||||||
|
- name: mycm
|
||||||
|
configMap:
|
||||||
|
name: mycm
|
||||||
|
`
|
||||||
|
|
||||||
var sharedNamespacePodYaml = `
|
var sharedNamespacePodYaml = `
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Pod
|
kind: Pod
|
||||||
@ -1235,6 +1254,16 @@ var _ = Describe("Podman play kube", func() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman play kube with non-existing configmap", func() {
|
||||||
|
err := writeYaml(podWithoutConfigMapDefined, kubeYaml)
|
||||||
|
Expect(err).To(BeNil())
|
||||||
|
|
||||||
|
kube := podmanTest.Podman([]string{"play", "kube", kubeYaml})
|
||||||
|
kube.WaitWithDefaultTimeout()
|
||||||
|
Expect(kube).Should(Exit(125))
|
||||||
|
Expect(kube.ErrorToString()).To(ContainSubstring("failed to create volume \"mycm\": no such ConfigMap \"mycm\""))
|
||||||
|
})
|
||||||
|
|
||||||
It("podman play kube test HostAliases with --no-hosts", func() {
|
It("podman play kube test HostAliases with --no-hosts", func() {
|
||||||
pod := getPod(withHostAliases("192.168.1.2", []string{
|
pod := getPod(withHostAliases("192.168.1.2", []string{
|
||||||
"test1.podman.io",
|
"test1.podman.io",
|
||||||
|
Reference in New Issue
Block a user