Skip to content

Commit

Permalink
Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit91 committed May 27, 2024
1 parent 9e21905 commit 1552595
Showing 1 changed file with 6 additions and 21 deletions.
27 changes: 6 additions & 21 deletions controllers/deployment/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,35 +197,20 @@ func (c *controller) isNewSetRequired(r *controllers.Ctx[*v2.FirewallDeployment]
oldS = &latestSet.Spec.Template.Spec
)

ok := sizeHasChanged(newS, oldS)
if ok {
if newS.Size != oldS.Size {
r.Log.Info("firewall size has changed", "size", newS.Size)
return ok
return true
}

ok = osImageHasChanged(newS, oldS)
if ok {
if newS.Image != oldS.Image {
r.Log.Info("firewall image has changed", "image", newS.Image)
return ok
return true
}

ok = networksHaveChanged(newS, oldS)
if ok {
if !sets.NewString(oldS.Networks...).Equal(sets.NewString(newS.Networks...)) {
r.Log.Info("firewall networks have changed", "networks", newS.Networks)
return ok
return true
}

return false
}

func sizeHasChanged(newS *v2.FirewallSpec, oldS *v2.FirewallSpec) bool {
return newS.Size != oldS.Size
}

func osImageHasChanged(newS *v2.FirewallSpec, oldS *v2.FirewallSpec) bool {
return newS.Image != oldS.Image
}

func networksHaveChanged(newS *v2.FirewallSpec, oldS *v2.FirewallSpec) bool {
return !sets.NewString(oldS.Networks...).Equal(sets.NewString(newS.Networks...))
}

0 comments on commit 1552595

Please sign in to comment.