Skip to content

Commit fb84469

Browse files
committed
Adjust maxLoc logic, add newlines
1 parent fa1ab61 commit fb84469

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

internal/controller/nginx/config/servers.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ func updateExternalLocationsForRule(
421421
mirrorPercentage,
422422
)
423423
}
424+
424425
return extLocations
425426
}
426427

@@ -469,6 +470,7 @@ func createInternalLocationsForRule(
469470
internalLocations = append(internalLocations, intLocation)
470471
matches = append(matches, match)
471472
}
473+
472474
return internalLocations, matches
473475
}
474476

@@ -511,13 +513,15 @@ func createInferenceLocationsForRule(
511513
locs = append(locs, intLocation)
512514
}
513515
locs = append(locs, extLocations...)
516+
514517
return locs
515518
}
516519

517520
func needsInternalLocationsForMatches(rule dataplane.PathRule) bool {
518521
if len(rule.MatchRules) > 1 {
519522
return true
520523
}
524+
521525
return len(rule.MatchRules) == 1 && !isPathOnlyMatch(rule.MatchRules[0].Match)
522526
}
523527

@@ -530,13 +534,13 @@ type pathAndTypeMap map[string]map[dataplane.PathType]struct{}
530534
// 2. Each path rule may have an additional location if it contains non-path-only matches.
531535
// 3. Each prefix path rule may have an additional location if it doesn't contain trailing slash.
532536
// 4. There may be an additional location for the default root path.
533-
// 5. There may be an additional location for the inference extension.
537+
// 5. There may be an additional location per parent location for the inference extension.
534538
// We also return a map of all paths and their types.
535539
func getMaxLocationCountAndPathMap(pathRules []dataplane.PathRule) (int, pathAndTypeMap) {
536540
maxLocs := 1
537541
pathsAndTypes := make(pathAndTypeMap)
538542
for _, rule := range pathRules {
539-
maxLocs += len(rule.MatchRules) + 3
543+
maxLocs += (len(rule.MatchRules) * 2) + 2
540544
if pathsAndTypes[rule.Path] == nil {
541545
pathsAndTypes[rule.Path] = map[dataplane.PathType]struct{}{
542546
rule.PathType: {},

0 commit comments

Comments
 (0)