Skip to content

Commit e13d020

Browse files
committed
Refactor argument length
1 parent f8fc8e8 commit e13d020

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

internal/controller/nginx/config/servers.go

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -291,12 +291,10 @@ func createLocations(
291291
if !needsInternalLocations(rule) {
292292
for _, r := range rule.MatchRules {
293293
extLocations = updateLocations(
294-
r.Filters,
295-
extLocations,
296294
r,
295+
rule,
296+
extLocations,
297297
server.Port,
298-
rule.Path,
299-
rule.GRPC,
300298
keepAliveCheck,
301299
mirrorPercentage,
302300
)
@@ -315,12 +313,10 @@ func createLocations(
315313
)
316314

317315
intLocation = updateLocation(
318-
r.Filters,
319-
intLocation,
320316
r,
317+
rule,
318+
intLocation,
321319
server.Port,
322-
rule.Path,
323-
rule.GRPC,
324320
keepAliveCheck,
325321
mirrorPercentage,
326322
)
@@ -453,15 +449,17 @@ func initializeInternalLocation(
453449

454450
// updateLocation updates a location with any relevant configurations, like proxy_pass, filters, tls settings, etc.
455451
func updateLocation(
456-
filters dataplane.HTTPFilters,
457-
location http.Location,
458452
matchRule dataplane.MatchRule,
453+
pathRule dataplane.PathRule,
454+
location http.Location,
459455
listenerPort int32,
460-
path string,
461-
grpc bool,
462456
keepAliveCheck keepAliveChecker,
463457
mirrorPercentage *float64,
464458
) http.Location {
459+
filters := matchRule.Filters
460+
path := pathRule.Path
461+
grpc := pathRule.GRPC
462+
465463
if filters.InvalidFilter != nil {
466464
location.Return = &http.Return{Code: http.StatusInternalServerError}
467465
return location
@@ -588,25 +586,21 @@ func updateLocationProxySettings(
588586
// updateLocations updates the existing locations with any relevant configurations, like proxy_pass,
589587
// filters, tls settings, etc.
590588
func updateLocations(
591-
filters dataplane.HTTPFilters,
592-
buildLocations []http.Location,
593589
matchRule dataplane.MatchRule,
590+
pathRule dataplane.PathRule,
591+
buildLocations []http.Location,
594592
listenerPort int32,
595-
path string,
596-
grpc bool,
597593
keepAliveCheck keepAliveChecker,
598594
mirrorPercentage *float64,
599595
) []http.Location {
600596
updatedLocations := make([]http.Location, len(buildLocations))
601597

602598
for i, loc := range buildLocations {
603599
updatedLocations[i] = updateLocation(
604-
filters,
605-
loc,
606600
matchRule,
601+
pathRule,
602+
loc,
607603
listenerPort,
608-
path,
609-
grpc,
610604
keepAliveCheck,
611605
mirrorPercentage,
612606
)

0 commit comments

Comments
 (0)