Skip to content

Commit 45283d9

Browse files
committed
Refactor servers tempRule for deep copy
1 parent 2114de8 commit 45283d9

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

internal/controller/nginx/config/servers.go

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -594,8 +594,17 @@ func createInternalLocationsForRule(
594594
// we need to update the rule to only have that backend for the location.
595595
// This ensures the correct name gets generated to correlate with the split clients generation.
596596
// If there is only one backend, this is effectively a no-op.
597-
tempRule := r
598-
tempRule.BackendGroup.Backends = []dataplane.Backend{b}
597+
tempRule := dataplane.MatchRule{
598+
Source: r.Source,
599+
Match: r.Match,
600+
Filters: r.Filters,
601+
BackendGroup: dataplane.BackendGroup{
602+
Source: r.BackendGroup.Source,
603+
RuleIdx: r.BackendGroup.RuleIdx,
604+
PathRuleIdx: r.BackendGroup.PathRuleIdx,
605+
Backends: []dataplane.Backend{b}, // Only include the current backend
606+
},
607+
}
599608
intProxyPassLocation = updateLocation(
600609
tempRule,
601610
rule,
@@ -726,8 +735,17 @@ func createInferenceLocationsForRule(
726735
// we need to update the rule to only have that backend for the location.
727736
// This ensures the correct name gets generated to correlate with the split clients generation.
728737
// If there is only one backend, this is effectively a no-op.
729-
tempRule := r
730-
tempRule.BackendGroup.Backends = []dataplane.Backend{b}
738+
tempRule := dataplane.MatchRule{
739+
Source: r.Source,
740+
Match: r.Match,
741+
Filters: r.Filters,
742+
BackendGroup: dataplane.BackendGroup{
743+
Source: r.BackendGroup.Source,
744+
RuleIdx: r.BackendGroup.RuleIdx,
745+
PathRuleIdx: r.BackendGroup.PathRuleIdx,
746+
Backends: []dataplane.Backend{b}, // Only include the current backend
747+
},
748+
}
731749
intProxyPassLocation = updateLocation(
732750
tempRule,
733751
rule,

0 commit comments

Comments
 (0)