Skip to content

Commit

Permalink
rename var
Browse files Browse the repository at this point in the history
Signed-off-by: Karol Szwaj <[email protected]>
  • Loading branch information
cnvergence committed Dec 17, 2024
1 parent 08d2d26 commit 15e3cf6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/controller/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (c *Controller) handleAddNamespace(key string) error {
namespace := cachedNs.DeepCopy()

var ls string
var lss, cidrs, excludeIps, ipPools []string
var lss, cidrs, excludeIps, ipPoolsAnnotation []string
subnets, err := c.subnetsLister.List(labels.Everything())
if err != nil {
klog.Errorf("failed to list subnets %v", err)
Expand Down Expand Up @@ -158,7 +158,7 @@ func (c *Controller) handleAddNamespace(key string) error {

for _, ipPool := range ipPoolList {
if slices.Contains(ipPool.Spec.Namespaces, key) {
ipPools = append(ipPools, ipPool.Name)
ipPoolsAnnotation = append(ipPoolsAnnotation, ipPool.Name)
break
}
}
Expand Down Expand Up @@ -202,18 +202,18 @@ func (c *Controller) handleAddNamespace(key string) error {
} else if namespace.Annotations[util.LogicalSwitchAnnotation] == strings.Join(lss, ",") &&
namespace.Annotations[util.CidrAnnotation] == strings.Join(cidrs, ";") &&
namespace.Annotations[util.ExcludeIpsAnnotation] == strings.Join(excludeIps, ";") &&
namespace.Annotations[util.IPPoolAnnotation] == strings.Join(ipPools, ",") {
namespace.Annotations[util.IPPoolAnnotation] == strings.Join(ipPoolsAnnotation, ",") {
return nil
}

namespace.Annotations[util.LogicalSwitchAnnotation] = strings.Join(lss, ",")
namespace.Annotations[util.CidrAnnotation] = strings.Join(cidrs, ";")
namespace.Annotations[util.ExcludeIpsAnnotation] = strings.Join(excludeIps, ";")

if len(ipPools) == 0 {
if len(ipPoolsAnnotation) == 0 {
delete(namespace.Annotations, util.IPPoolAnnotation)
} else {
namespace.Annotations[util.IPPoolAnnotation] = strings.Join(ipPools, ",")
namespace.Annotations[util.IPPoolAnnotation] = strings.Join(ipPoolsAnnotation, ",")
}

patch, err := util.GenerateStrategicMergePatchPayload(cachedNs, namespace)
Expand Down

0 comments on commit 15e3cf6

Please sign in to comment.