Skip to content

Commit 19abe15

Browse files
committed
BUG/MINOR: redispatch: allow interval of 0
1 parent 8380665 commit 19abe15

8 files changed

Lines changed: 13 additions & 19 deletions

File tree

.aspell.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ allowed:
129129
- readme
130130
- recursivity
131131
- recv
132+
- redispatch
132133
- redoc
133134
- reimplement
134135
- releaser

configuration/configuration.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -995,9 +995,8 @@ func (s *SectionParser) redispatch() interface{} {
995995
return nil
996996
}
997997
d := data.(*types.OptionRedispatch)
998-
br := &models.Redispatch{}
999-
if d.Interval != nil {
1000-
br.Interval = *d.Interval
998+
br := &models.Redispatch{
999+
Interval: d.Interval,
10011000
}
10021001
if d.NoOption {
10031002
d := "disabled"
@@ -2436,15 +2435,12 @@ func (s *SectionObject) redispatch(field reflect.Value) error {
24362435
return misc.CreateTypeAssertError("option redispatch")
24372436
}
24382437
d := &types.OptionRedispatch{
2439-
Interval: &br.Interval,
2438+
Interval: br.Interval,
24402439
NoOption: false,
24412440
}
24422441
if *br.Enabled == "disabled" {
24432442
d.NoOption = true
24442443
}
2445-
if br.Interval == 0 {
2446-
d = nil
2447-
}
24482444
if err := s.set("option redispatch", d); err != nil {
24492445
return err
24502446
}

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
@@ -10597,7 +10597,7 @@ definitions:
1059710597
type: string
1059810598
interval:
1059910599
type: integer
10600-
x-nullable: false
10600+
x-nullable: true
1060110601
required:
1060210602
- enabled
1060310603
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: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ func TestCreateEditDeleteBackend(t *testing.T) {
222222
Disabled: true,
223223
Redispatch: &models.Redispatch{
224224
Enabled: misc.StringP("enabled"),
225-
Interval: 0,
225+
Interval: misc.Int64P(0),
226226
},
227227
},
228228
}
@@ -239,9 +239,6 @@ func TestCreateEditDeleteBackend(t *testing.T) {
239239
t.Error(err.Error())
240240
}
241241

242-
// A redispatch with a zero interval is automatically removed from configuration.
243-
b.Redispatch = nil
244-
245242
var givenJSONB []byte
246243
givenJSONB, err = b.MarshalBinary()
247244
if err != nil {

0 commit comments

Comments
 (0)