Skip to content

Commit

Permalink
refactor: rename source file and function.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodman10 committed Jul 31, 2023
1 parent ee52341 commit 6af4d88
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/dataplane/parser/translate_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func maybePrependRegexPrefix(path, controllerPrefix string, applyLegacyHeuristic
func applyExpressionToIngressRules(result *ingressRules) {
for _, svc := range result.ServiceNameToServices {
for i := range svc.Routes {
translators.ApplyExpressionToKongRoute(&svc.Routes[i])
translators.ApplyExpressionToL4KongRoute(&svc.Routes[i])
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package translators

import (
"github.com/samber/lo"

"github.com/kong/kubernetes-ingress-controller/v2/internal/dataplane/kongstate"
"github.com/kong/kubernetes-ingress-controller/v2/internal/dataplane/parser/atc"
"github.com/samber/lo"
)

func ApplyExpressionToKongRoute(r *kongstate.Route) {
// ApplyExpressionToL4KongRoute convert route flavor from traditional to expressions
// against protocols, snis and dest ports.
func ApplyExpressionToL4KongRoute(r *kongstate.Route) {
matchers := []atc.Matcher{}

protocolMatcher := protocolMatcherFromProtocols(lo.Map(r.Route.Protocols, func(item *string, _ int) string { return *item }))
Expand All @@ -15,7 +18,7 @@ func ApplyExpressionToKongRoute(r *kongstate.Route) {
sniMatcher := sniMatcherFromSNIs(lo.Map(r.Route.SNIs, func(item *string, _ int) string { return *item }))
matchers = append(matchers, sniMatcher)

//TODO(rodman10): replace with helper function.
// TODO(rodman10): replace with helper function.
portMatchers := make([]atc.Matcher, 0, len(r.Destinations))
for _, dst := range r.Destinations {
portMatchers = append(portMatchers, atc.NewPredicate(atc.FieldNetDstPort, atc.OpEqual, atc.IntLiteral(*dst.Port)))
Expand Down

0 comments on commit 6af4d88

Please sign in to comment.