Skip to content

Commit bd81297

Browse files
AlexsJonesskyerus
andauthored
adds nil pointer check (#75)
* adds nil pointer check Signed-off-by: Alex Jones <[email protected]> * Update webhooks/pod_webhook.go Co-authored-by: Skye Gill <[email protected]> Signed-off-by: Alex Jones <[email protected]> Signed-off-by: Alex Jones <[email protected]> Signed-off-by: Alex Jones <[email protected]> Co-authored-by: Skye Gill <[email protected]>
1 parent 2b1d89f commit bd81297

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

webhooks/pod_webhook.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ func (m *PodMutator) injectSidecar(pod *corev1.Pod, configMap string, featureFla
173173
FlagDTag = os.Getenv("FLAGD_VERSION")
174174
}
175175

176+
var envs []corev1.EnvVar
177+
if featureFlag.Spec.FlagDSpec != nil {
178+
envs = featureFlag.Spec.FlagDSpec.Envs
179+
}
180+
176181
pod.Spec.Containers = append(pod.Spec.Containers, corev1.Container{
177182
Name: "flagd",
178183
Image: "ghcr.io/open-feature/flagd:" + FlagDTag,
@@ -184,7 +189,7 @@ func (m *PodMutator) injectSidecar(pod *corev1.Pod, configMap string, featureFla
184189
MountPath: "/etc/flagd",
185190
},
186191
},
187-
Env: featureFlag.Spec.FlagDSpec.Envs,
192+
Env: envs,
188193
})
189194
return json.Marshal(pod)
190195
}

0 commit comments

Comments
 (0)