Skip to content

Commit

Permalink
Reduce complexity
Browse files Browse the repository at this point in the history
  • Loading branch information
CoreyCook8 authored and ccojocar committed Jan 23, 2024
1 parent 21f80fd commit 58cc418
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions internal/pkg/webhooks/binding/binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,16 +205,14 @@ func (p *podBinder) updatePod(ctx context.Context, profilebindings []profilebind
}
}

if !podChanged {
if podBindProfile == nil || podProfileBinding == nil {
return pod, admission.Allowed("pod unchanged")
}
podChanged = p.addPodSecurityContext(pod, *podBindProfile)
if podChanged {
if err := p.addPodToBinding(ctx, podID, podProfileBinding); err != nil {
return pod, admission.Errored(http.StatusInternalServerError, err)
}
}
if !podChanged && (podBindProfile == nil || podProfileBinding == nil) {
return pod, admission.Allowed("pod unchanged")
}
if !p.addPodSecurityContext(pod, *podBindProfile) {
return pod, admission.Allowed("pod unchanged")
}
if err := p.addPodToBinding(ctx, podID, podProfileBinding); err != nil {
return pod, admission.Errored(http.StatusInternalServerError, err)
}
return pod, admission.Response{}
}
Expand Down

0 comments on commit 58cc418

Please sign in to comment.