Skip to content

Commit dc5766f

Browse files
mjuragaGopher Bot
authored andcommitted
BUG/MINOR: redispatch: allow interval of 0
1 parent 3725b10 commit dc5766f

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
@@ -128,6 +128,7 @@ allowed:
128128
- readme
129129
- recursivity
130130
- recv
131+
- redispatch
131132
- redoc
132133
- reimplement
133134
- 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
@@ -10589,7 +10589,7 @@ definitions:
1058910589
type: string
1059010590
interval:
1059110591
type: integer
10592-
x-nullable: false
10592+
x-nullable: true
1059310593
required:
1059410594
- enabled
1059510595
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)