Skip to content

Commit 37c97e9

Browse files
committed
- address feedback
Signed-off-by: greeshma1196 <greeshma.mathew@gmail.com>
1 parent 6d88c57 commit 37c97e9

1 file changed

Lines changed: 11 additions & 17 deletions

File tree

dataclients/kubernetes/clusterstate.go

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,7 @@ func (state *clusterState) GetEndpointSlicesByService(zone, namespace, name, pro
105105
state.cachedEndpointSlices[epID] = targets
106106
}
107107

108-
if zone != "" {
109-
targets = filterByZone(zone, targets)
110-
}
111-
112-
return targets
108+
return filterByZone(zone, targets)
113109
}
114110

115111
// getEndpointAddresses returns the list of all addresses for the given service using endpoints or endpointslices.
@@ -196,22 +192,20 @@ func (state *clusterState) GetEndpointSlicesByTarget(zone, namespace, name, prot
196192
state.cachedEndpointSlices[epID] = targets
197193
}
198194

199-
if zone != "" {
200-
targets = filterByZone(zone, targets)
201-
}
202-
203-
return targets
195+
return filterByZone(zone, targets)
204196
}
205197

206198
func filterByZone(zone string, targets []skipperEndpoint) []skipperEndpoint {
207-
var zoneTargets []skipperEndpoint
208-
for _, target := range targets {
209-
if target.Zone == zone {
210-
zoneTargets = append(zoneTargets, target)
199+
if zone != "" {
200+
var zoneTargets []skipperEndpoint
201+
for _, target := range targets {
202+
if target.Zone == zone {
203+
zoneTargets = append(zoneTargets, target)
204+
}
205+
}
206+
if len(zoneTargets) >= minEndpointsByZone {
207+
return zoneTargets
211208
}
212-
}
213-
if len(zoneTargets) >= minEndpointsByZone {
214-
return zoneTargets
215209
}
216210
return targets
217211
}

0 commit comments

Comments
 (0)