Skip to content

Commit 733e1e9

Browse files
committed
update variable name and improve fieldalignment in struct
1 parent 698f6ee commit 733e1e9

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

internal/controller/nginx/config/http/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ const (
120120
// Upstream holds all configuration for an HTTP upstream.
121121
type Upstream struct {
122122
Name string
123-
ZoneSize string // format: 512k, 1m
123+
ZoneSize string
124124
StateFile string
125-
KeepAlive UpstreamKeepAlive
126125
LoadBalancingMethod string
126+
KeepAlive UpstreamKeepAlive
127127
Servers []UpstreamServer
128128
}
129129

internal/controller/nginx/config/upstreams.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const (
3333
// stateDir is the directory for storing state files.
3434
stateDir = "/var/lib/nginx/state"
3535
// default load balancing method.
36-
randomTwoLeastConnLB = "random two least_conn"
36+
defaultLBMethod = "random two least_conn"
3737
)
3838

3939
// keepAliveChecker takes an upstream name and returns if it has keep alive settings enabled.
@@ -187,7 +187,7 @@ func (g GeneratorImpl) createUpstream(
187187
}
188188
}
189189

190-
chosenLBMethod := randomTwoLeastConnLB
190+
chosenLBMethod := defaultLBMethod
191191
if upstreamPolicySettings.LoadBalancingMethod != "" {
192192
chosenLBMethod = upstreamPolicySettings.LoadBalancingMethod
193193
}

internal/controller/nginx/config/upstreams_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ func TestCreateUpstreams(t *testing.T) {
213213
Address: "10.0.0.2:80",
214214
},
215215
},
216-
LoadBalancingMethod: randomTwoLeastConnLB,
216+
LoadBalancingMethod: defaultLBMethod,
217217
},
218218
{
219219
Name: "up2",
@@ -223,7 +223,7 @@ func TestCreateUpstreams(t *testing.T) {
223223
Address: "11.0.0.0:80",
224224
},
225225
},
226-
LoadBalancingMethod: randomTwoLeastConnLB,
226+
LoadBalancingMethod: defaultLBMethod,
227227
},
228228
{
229229
Name: "up3",
@@ -242,7 +242,7 @@ func TestCreateUpstreams(t *testing.T) {
242242
Address: "[fd00:10:244:1::7]:80",
243243
},
244244
},
245-
LoadBalancingMethod: randomTwoLeastConnLB,
245+
LoadBalancingMethod: defaultLBMethod,
246246
},
247247
{
248248
Name: "up5-usp",
@@ -347,7 +347,7 @@ func TestCreateUpstream(t *testing.T) {
347347
Address: "10.0.0.3:80",
348348
},
349349
},
350-
LoadBalancingMethod: randomTwoLeastConnLB,
350+
LoadBalancingMethod: defaultLBMethod,
351351
},
352352
msg: "multiple endpoints",
353353
},
@@ -370,7 +370,7 @@ func TestCreateUpstream(t *testing.T) {
370370
Address: "[fd00:10:244:1::7]:80",
371371
},
372372
},
373-
LoadBalancingMethod: randomTwoLeastConnLB,
373+
LoadBalancingMethod: defaultLBMethod,
374374
},
375375
msg: "endpoint ipv6",
376376
},
@@ -502,7 +502,7 @@ func TestCreateUpstream(t *testing.T) {
502502
Address: "10.0.0.1:80",
503503
},
504504
},
505-
LoadBalancingMethod: randomTwoLeastConnLB,
505+
LoadBalancingMethod: defaultLBMethod,
506506
},
507507
msg: "empty upstreamSettingsPolicies",
508508
},
@@ -546,7 +546,7 @@ func TestCreateUpstream(t *testing.T) {
546546
Time: "5s",
547547
Timeout: "10s",
548548
},
549-
LoadBalancingMethod: randomTwoLeastConnLB,
549+
LoadBalancingMethod: defaultLBMethod,
550550
},
551551
msg: "upstreamSettingsPolicy with only keep alive settings",
552552
},
@@ -603,7 +603,7 @@ func TestCreateUpstream(t *testing.T) {
603603
Resolve: true,
604604
},
605605
},
606-
LoadBalancingMethod: randomTwoLeastConnLB,
606+
LoadBalancingMethod: defaultLBMethod,
607607
},
608608
msg: "ExternalName service with DNS name",
609609
},
@@ -642,7 +642,7 @@ func TestCreateUpstream(t *testing.T) {
642642
Address: "[fd00:10:244:1::7]:80",
643643
},
644644
},
645-
LoadBalancingMethod: randomTwoLeastConnLB,
645+
LoadBalancingMethod: defaultLBMethod,
646646
},
647647
msg: "mixed IP addresses and DNS names",
648648
},
@@ -663,9 +663,9 @@ func TestCreateUpstreamPlus(t *testing.T) {
663663
gen := GeneratorImpl{plus: true}
664664

665665
tests := []struct {
666+
expectedUpstream http.Upstream
666667
msg string
667668
stateUpstream dataplane.Upstream
668-
expectedUpstream http.Upstream
669669
}{
670670
{
671671
msg: "with endpoints",
@@ -687,7 +687,7 @@ func TestCreateUpstreamPlus(t *testing.T) {
687687
Address: "10.0.0.1:80",
688688
},
689689
},
690-
LoadBalancingMethod: randomTwoLeastConnLB,
690+
LoadBalancingMethod: defaultLBMethod,
691691
},
692692
},
693693
{

0 commit comments

Comments
 (0)