Skip to content

Commit

Permalink
minor: countPathRoutes function (#2961)
Browse files Browse the repository at this point in the history
The name could be a little bit misleading because actually this function
calculates the number of Path{,Subtree} predicates in the single route.
Nobody calculates the number of routes here, there is only one route
which this function takes as input.
Therefore n variable corresponds to the number of predicates, not the
routes how it seems to be when taking a look at the code.

Signed-off-by: Roman Zavodskikh <[email protected]>
Co-authored-by: Roman Zavodskikh <[email protected]>
  • Loading branch information
RomanZavodskikh and Roman Zavodskikh authored Mar 1, 2024
1 parent 7041036 commit 9316c43
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions dataclients/kubernetes/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,11 @@ func addExtraRoutes(ic *ingressContext, ruleHost, path, pathType, eastWestDomain
ruleHost+strings.ReplaceAll(path, "/", "_"),
extraIndex)
setPathV1(ic.pathMode, &route, pathType, path)
if n := countPathRoutes(&route); n <= 1 {
if n := countPathPredicates(&route); n <= 1 {
ic.addHostRoute(ruleHost, &route)
ic.redirect.updateHost(ruleHost)
} else {
ic.logger.Errorf("Failed to add route having %d path routes: %v", n, r)
ic.logger.Errorf("Ignoring route due to multiple path predicates: %d path predicates, route: %v", n, route)
}
if enableEastWest {
ewRoute := createEastWestRouteIng(eastWestDomain, name, ns, &route)
Expand All @@ -209,7 +209,7 @@ func addExtraRoutes(ic *ingressContext, ruleHost, path, pathType, eastWestDomain
}
}

func countPathRoutes(r *eskip.Route) int {
func countPathPredicates(r *eskip.Route) int {
i := 0
for _, p := range r.Predicates {
if p.Name == "PathSubtree" || p.Name == "Path" {
Expand Down

0 comments on commit 9316c43

Please sign in to comment.