Skip to content

Commit 32dd41d

Browse files
committed
Add clarifying comment
1 parent 012cc3f commit 32dd41d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

internal/controller/state/graph/route_common.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -870,12 +870,17 @@ func findAttachableListeners(ref *ParentRef, listeners []*Listener) ([]*Listener
870870
if sectionName != "" {
871871
for _, l := range listeners {
872872
if l.Name == sectionName {
873-
if l.Attachable && (ref.Port == nil || l.Source.Port == *ref.Port) {
873+
listenerPortMatches := ref.Port == nil || l.Source.Port == *ref.Port
874+
if l.Attachable && listenerPortMatches {
874875
return []*Listener{l}, true
875876
}
876-
if ref.Port != nil && l.Source.Port != *ref.Port {
877+
878+
if !listenerPortMatches {
877879
return nil, false
878880
}
881+
882+
// This is the case where the port of parentRef is nil or the same as the listener port.
883+
// We return true because we have technically found a listener, but its not attachable.
879884
return nil, true
880885
}
881886
}

0 commit comments

Comments
 (0)