Skip to content

Commit 60037d7

Browse files
committed
Revert parentRefIndex
1 parent b7d9606 commit 60037d7

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

internal/controller/state/graph/route_common.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,7 @@ func buildSectionNameRefs(
294294
return nil
295295
}
296296

297-
parentRefIndex := 0
298-
299-
for _, p := range parentRefs {
297+
for i, p := range parentRefs {
300298
gw := findGatewayForParentRef(p, routeNamespace, gws)
301299
if gw == nil {
302300
continue
@@ -317,17 +315,16 @@ func buildSectionNameRefs(
317315
}
318316

319317
sectionNameRefs = append(sectionNameRefs, ParentRef{
320-
Idx: parentRefIndex,
318+
// if the ParentRefs we create are for each listener in the same gateway, we keep the
319+
// parentRefIndex the same so when we look at a route's parentRef's we can see
320+
// if the parentRef is a unique parentRef or one we created internally
321+
Idx: i,
321322
Gateway: CreateParentRefGateway(gw),
322323
SectionName: &l.Source.Name,
323324
Port: p.Port,
324325
})
325326
}
326327

327-
// if the ParentRefs we create are for each listener in the same gateway, we keep the
328-
// parentRefIndex the same so when we look at a route's parentRef's we can see
329-
// if the parentRef is a unique parentRef or one we created internally
330-
parentRefIndex++
331328
continue
332329
}
333330

@@ -337,12 +334,11 @@ func buildSectionNameRefs(
337334
}
338335

339336
sectionNameRefs = append(sectionNameRefs, ParentRef{
340-
Idx: parentRefIndex,
337+
Idx: i,
341338
Gateway: CreateParentRefGateway(gw),
342339
SectionName: p.SectionName,
343340
Port: p.Port,
344341
})
345-
parentRefIndex++
346342
}
347343

348344
return sectionNameRefs, nil

internal/controller/state/graph/route_common_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,27 +104,27 @@ func TestBuildSectionNameRefs(t *testing.T) {
104104
SectionName: parentRefs[0].SectionName,
105105
},
106106
{
107-
Idx: 1,
107+
Idx: 2,
108108
Gateway: CreateParentRefGateway(gws[gwNsName2]),
109109
SectionName: parentRefs[2].SectionName,
110110
},
111111
{
112-
Idx: 2,
112+
Idx: 3,
113113
Gateway: CreateParentRefGateway(gws[gwNsName1]),
114114
SectionName: parentRefs[3].SectionName,
115115
},
116116
{
117-
Idx: 3,
117+
Idx: 4,
118118
Gateway: CreateParentRefGateway(gws[gwNsName2]),
119119
SectionName: parentRefs[4].SectionName,
120120
},
121121
{
122-
Idx: 4,
122+
Idx: 6,
123123
Gateway: CreateParentRefGateway(gws[gwNsName3]),
124124
SectionName: helpers.GetPointer[gatewayv1.SectionName]("http"),
125125
},
126126
{
127-
Idx: 4,
127+
Idx: 6,
128128
Gateway: CreateParentRefGateway(gws[gwNsName3]),
129129
SectionName: helpers.GetPointer[gatewayv1.SectionName]("https"),
130130
},

0 commit comments

Comments
 (0)