@@ -216,8 +216,10 @@ func collectOrderedGateways(
216
216
services map [types.NamespacedName ]* ReferencedService ,
217
217
gateways map [types.NamespacedName ]* Gateway ,
218
218
existingNGFGatewayAncestors map [types.NamespacedName ]struct {},
219
- ) ( existingGateways []types.NamespacedName , newGateways []types. NamespacedName ) {
219
+ ) []types.NamespacedName {
220
220
seenGateways := make (map [types.NamespacedName ]struct {})
221
+ existingGateways := make ([]types.NamespacedName , 0 )
222
+ newGateways := make ([]types.NamespacedName , 0 )
221
223
222
224
// Process services in spec order to maintain deterministic gateway ordering
223
225
for _ , refs := range policy .Spec .TargetRefs {
@@ -252,7 +254,8 @@ func collectOrderedGateways(
252
254
sortGatewaysByCreationTime (existingGateways , gateways )
253
255
sortGatewaysByCreationTime (newGateways , gateways )
254
256
255
- return existingGateways , newGateways
257
+ existingGateways = append (existingGateways , newGateways ... )
258
+ return existingGateways
256
259
}
257
260
258
261
func extractExistingNGFGatewayAncestors (
@@ -288,11 +291,12 @@ func addGatewaysForBackendTLSPolicies(
288
291
) {
289
292
for _ , backendTLSPolicy := range backendTLSPolicies {
290
293
existingNGFGatewayAncestors := extractExistingNGFGatewayAncestors (backendTLSPolicy .Source , ctlrName )
291
- existingGateways , newGateways := collectOrderedGateways (
292
- backendTLSPolicy .Source , services , gateways , existingNGFGatewayAncestors )
293
-
294
- existingGateways = append (existingGateways , newGateways ... )
295
- orderedGateways := existingGateways
294
+ orderedGateways := collectOrderedGateways (
295
+ backendTLSPolicy .Source ,
296
+ services ,
297
+ gateways ,
298
+ existingNGFGatewayAncestors ,
299
+ )
296
300
297
301
ancestorCount := countNonNGFAncestors (backendTLSPolicy .Source , ctlrName )
298
302
0 commit comments