Skip to content

Commit 642539e

Browse files
committed
BUG/MINOR: redispatch: allow interval of 0
1 parent a69dda9 commit 642539e

File tree

7 files changed

+25
-17
lines changed

7 files changed

+25
-17
lines changed

configuration/configuration.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -981,9 +981,8 @@ func (s *SectionParser) redispatch() interface{} {
981981
return nil
982982
}
983983
d := data.(*types.OptionRedispatch)
984-
br := &models.Redispatch{}
985-
if d.Interval != nil {
986-
br.Interval = *d.Interval
984+
br := &models.Redispatch{
985+
Interval: d.Interval,
987986
}
988987
if d.NoOption {
989988
d := "disabled"
@@ -2370,7 +2369,7 @@ func (s *SectionObject) redispatch(field reflect.Value) error {
23702369
return misc.CreateTypeAssertError("option redispatch")
23712370
}
23722371
d := &types.OptionRedispatch{
2373-
Interval: &br.Interval,
2372+
Interval: br.Interval,
23742373
NoOption: false,
23752374
}
23762375
if *br.Enabled == "disabled" {

models/redispatch.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

models/redispatch_compare.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

models/redispatch_compare_test.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

specification/build/haproxy_spec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10030,7 +10030,7 @@ definitions:
1003010030
type: string
1003110031
interval:
1003210032
type: integer
10033-
x-nullable: false
10033+
x-nullable: true
1003410034
required:
1003510035
- enabled
1003610036
type: object

specification/models/configuration/misc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ redispatch:
151151
enum: [enabled, disabled]
152152
interval:
153153
type: integer
154-
x-nullable: false
154+
x-nullable: true
155155
errorfile:
156156
type: object
157157
x-display-name: Error File

test/backend_test.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,10 @@ func TestCreateEditDeleteBackend(t *testing.T) {
218218
{Name: "test_errors_all"},
219219
},
220220
Disabled: true,
221+
Redispatch: &models.Redispatch{
222+
Enabled: misc.StringP("enabled"),
223+
Interval: misc.Int64P(0),
224+
},
221225
},
222226
}
223227

@@ -317,7 +321,8 @@ func TestCreateEditDeleteBackend(t *testing.T) {
317321
Enabled: misc.StringP("enabled"),
318322
Except: "127.0.0.1",
319323
},
320-
}},
324+
},
325+
},
321326
{
322327
BackendBase: models.BackendBase{
323328
Name: "created",
@@ -385,7 +390,8 @@ func TestCreateEditDeleteBackend(t *testing.T) {
385390
{Cond: misc.StringP("if"), CondTest: misc.StringP("host_www")},
386391
{Cond: misc.StringP("unless"), CondTest: misc.StringP("missing_cl")},
387392
},
388-
}},
393+
},
394+
},
389395
}
390396

391397
for i, backend := range backends {
@@ -691,7 +697,8 @@ func TestCreateEditDeleteBackendHTTPConnectionMode(t *testing.T) {
691697
},
692698
},
693699
HTTPConnectionMode: "httpclose",
694-
}},
700+
},
701+
},
695702
expectedHTTPConnectionMode: "httpclose",
696703
},
697704
{
@@ -707,7 +714,8 @@ func TestCreateEditDeleteBackendHTTPConnectionMode(t *testing.T) {
707714
},
708715
},
709716
HTTPConnectionMode: "http-keep-alive",
710-
}},
717+
},
718+
},
711719
expectedHTTPConnectionMode: "http-keep-alive",
712720
},
713721
{
@@ -723,7 +731,8 @@ func TestCreateEditDeleteBackendHTTPConnectionMode(t *testing.T) {
723731
},
724732
},
725733
HTTPConnectionMode: "",
726-
}},
734+
},
735+
},
727736
expectedHTTPConnectionMode: "",
728737
},
729738
}

0 commit comments

Comments
 (0)