From 0bda1b0f8c5f17306a06adab0b1d92fc8a1e3560 Mon Sep 17 00:00:00 2001 From: Aldo Fuster Turpin Date: Fri, 22 Jul 2022 11:30:44 +0200 Subject: [PATCH] Add comments. Remove explanatory variable --- pkg/util/subnet/subnetsupdater.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/util/subnet/subnetsupdater.go b/pkg/util/subnet/subnetsupdater.go index 595ba25c8..3dc093b5d 100644 --- a/pkg/util/subnet/subnetsupdater.go +++ b/pkg/util/subnet/subnetsupdater.go @@ -10,6 +10,8 @@ import ( ) type Updater interface { + // AddEndpointsToSubnets adds the endpoints that either are missing in subnets + // or aren't in succeded state in the subnets AddEndpointsToSubnets(endpoints []string, subnets []*mgmtnetwork.Subnet) (updatedSubnets []*mgmtnetwork.Subnet) } @@ -26,12 +28,13 @@ func (um *UpdaterManager) AddEndpointsToSubnets(endpoints []string, subnets []*m return updatedSubnets } +// addEndpointsToSubnet adds the endpoints that either are missing in subnet +// or aren't in succeded state in the subnet func addEndpointsToSubnet(endpoints []string, subnet *mgmtnetwork.Subnet) (subnetChanged bool) { for _, endpoint := range endpoints { endpointFound, serviceEndpointPtr := subnetContainsEndpoint(subnet, endpoint) - endpointSucceded := serviceEndpointPtr != nil && serviceEndpointPtr.ProvisioningState == mgmtnetwork.Succeeded - if !endpointFound || !endpointSucceded { + if !endpointFound || serviceEndpointPtr.ProvisioningState != mgmtnetwork.Succeeded { addEndpointToSubnet(endpoint, subnet) subnetChanged = true }