mirror of
https://github.com/netbirdio/kubernetes-operator.git
synced 2026-05-22 17:11:40 -07:00
fix potential panic when acessing empty list (#88)
while fixing #87, noticed a couple lines down that if the containers spec has more than 1 container, the code probably intends to set Spec.Containers to a list with a single container, but is instead setting it to an empty list. The very next lines are trying to access the 1st element of this empty list, which will result in a panic
This commit is contained in:
@@ -242,7 +242,7 @@ func (r *NBRoutingPeerReconciler) handleDeployment(ctx context.Context, req ctrl
|
||||
updatedDeployment.Spec.Template.ObjectMeta.Labels = podLabels
|
||||
updatedDeployment.Spec.Template.Spec.Volumes = nbrp.Spec.Volumes
|
||||
if len(updatedDeployment.Spec.Template.Spec.Containers) != 1 {
|
||||
updatedDeployment.Spec.Template.Spec.Containers = []corev1.Container{}
|
||||
updatedDeployment.Spec.Template.Spec.Containers = []corev1.Container{{}}
|
||||
}
|
||||
updatedDeployment.Spec.Template.Spec.Containers[0].Name = "netbird"
|
||||
updatedDeployment.Spec.Template.Spec.Containers[0].Image = r.ClientImage
|
||||
|
||||
Reference in New Issue
Block a user