mirror of
https://github.com/YuzuZensai/netbird-kubernetes-operator.git
synced 2026-09-13 10:49:15 +00:00
Fix sidecar injection when pod annotations is nil. (#250)
When a pod does not have any annotations the injector will fail. This change adds a test for the case and also fixes the issue. Fixes #246 Signed-off-by: Philip Laine <philip.laine@gmail.com>
This commit is contained in:
@@ -172,6 +172,9 @@ func (d *PodNetbirdInjector) Default(ctx context.Context, pod *corev1.Pod) error
|
||||
return fmt.Errorf("unknown injection mode %s", sidecarProfile.Spec.InjectionMode)
|
||||
}
|
||||
|
||||
if pod.Annotations == nil {
|
||||
pod.Annotations = map[string]string{}
|
||||
}
|
||||
pod.Annotations[SidecarProfileAnnotation] = sidecarProfile.Name
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user