env: fix resource reference Optional nil pointer (#491)
Signed-off-by: Paulo Pires <pjpires@gmail.com>
This commit is contained in:
committed by
Robbie Zhang
parent
b44d5b9f22
commit
323c02d468
@@ -227,7 +227,7 @@ loop:
|
||||
vf := env.ValueFrom.ConfigMapKeyRef
|
||||
// Check whether the key reference is optional.
|
||||
// This will control whether we fail when unable to read the requested key.
|
||||
optional := vf != nil && *vf.Optional
|
||||
optional := vf != nil && vf.Optional != nil && *vf.Optional
|
||||
// Try to grab the referenced configmap.
|
||||
m, err := rm.GetConfigMap(vf.Name, pod.Namespace)
|
||||
if err != nil {
|
||||
@@ -279,7 +279,7 @@ loop:
|
||||
vf := env.ValueFrom.SecretKeyRef
|
||||
// Check whether the key reference is optional.
|
||||
// This will control whether we fail when unable to read the requested key.
|
||||
optional := vf != nil && *vf.Optional
|
||||
optional := vf != nil && vf.Optional != nil && *vf.Optional
|
||||
// Try to grab the referenced secret.
|
||||
s, err := rm.GetSecret(vf.Name, pod.Namespace)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user