@@ -462,7 +462,7 @@ func checkForRouteOverlap(route *L7Route, hostPortPaths map[string]string) *cond
462
462
port := parentRef .Attachment .ListenerPort
463
463
for _ , hostnames := range parentRef .Attachment .AcceptedHostnames {
464
464
mergedHostnames := getMergedHostnames (route , hostnames )
465
- if cond := checkHostnamesOverlap (route , mergedHostnames , port , hostPortPaths ); cond != nil {
465
+ if cond := checkURIsOverlap (route , mergedHostnames , port , hostPortPaths ); cond != nil {
466
466
return cond
467
467
}
468
468
}
@@ -483,47 +483,36 @@ func getMergedHostnames(route *L7Route, hostnames []string) []string {
483
483
}
484
484
485
485
func getHostnameMatches (hostname string , routeHostnames []v1.Hostname ) []string {
486
- foundExactMatch := false
487
486
moreSpecificHostnames := make ([]string , 0 )
488
487
489
488
for _ , h := range routeHostnames {
490
489
if hostname == string (h ) {
491
- foundExactMatch = true
492
- break
490
+ return []string {hostname }
493
491
}
494
- if Match (hostname , string (h )) {
492
+ if match (hostname , string (h )) {
495
493
moreSpecificHostnames = append (moreSpecificHostnames , GetMoreSpecificHostname (hostname , string (h )))
496
494
}
497
495
}
498
496
499
- if foundExactMatch {
500
- return []string {hostname }
501
- }
502
497
return moreSpecificHostnames
503
498
}
504
499
505
- func checkHostnamesOverlap (
506
- route * L7Route , hostnames []string , port v1.PortNumber , hostPortPaths map [string ]string ,
500
+ func checkURIsOverlap (
501
+ route * L7Route ,
502
+ hostnames []string ,
503
+ port v1.PortNumber ,
504
+ hostPortPaths map [string ]string ,
507
505
) * conditions.Condition {
508
506
for _ , hostname := range hostnames {
509
- if cond := checkHostnamePathsOverlap (route , hostname , port , hostPortPaths ); cond != nil {
510
- return cond
511
- }
512
- }
513
- return nil
514
- }
515
-
516
- func checkHostnamePathsOverlap (
517
- route * L7Route , hostname string , port v1.PortNumber , hostPortPaths map [string ]string ,
518
- ) * conditions.Condition {
519
- for _ , rule := range route .Spec .Rules {
520
- for _ , match := range rule .Matches {
521
- if match .Path != nil && match .Path .Value != nil {
522
- key := fmt .Sprintf ("%s:%d%s" , hostname , port , * match .Path .Value )
523
- if val , ok := hostPortPaths [key ]; ! ok {
524
- hostPortPaths [key ] = fmt .Sprintf ("%s/%s" , route .Source .GetNamespace (), route .Source .GetName ())
525
- } else {
526
- return createTargetConflictCondition (route , val )
507
+ for _ , rule := range route .Spec .Rules {
508
+ for _ , match := range rule .Matches {
509
+ if match .Path != nil && match .Path .Value != nil {
510
+ key := fmt .Sprintf ("%s:%d%s" , hostname , port , * match .Path .Value )
511
+ if val , ok := hostPortPaths [key ]; ! ok {
512
+ hostPortPaths [key ] = fmt .Sprintf ("%s/%s" , route .Source .GetNamespace (), route .Source .GetName ())
513
+ } else {
514
+ return createTargetConflictCondition (route , val )
515
+ }
527
516
}
528
517
}
529
518
}
0 commit comments