Skip to content

Commit 0115aa9

Browse files
committed
BUG/MINOR: redispatch: allow interval of 0
1 parent 8cf3734 commit 0115aa9

File tree

7 files changed

+12
-19
lines changed

7 files changed

+12
-19
lines changed

configuration/configuration.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -976,9 +976,8 @@ func (s *SectionParser) redispatch() interface{} {
976976
return nil
977977
}
978978
d := data.(*types.OptionRedispatch)
979-
br := &models.Redispatch{}
980-
if d.Interval != nil {
981-
br.Interval = *d.Interval
979+
br := &models.Redispatch{
980+
Interval: d.Interval,
982981
}
983982
if d.NoOption {
984983
d := "disabled"
@@ -2350,15 +2349,12 @@ func (s *SectionObject) redispatch(field reflect.Value) error {
23502349
return misc.CreateTypeAssertError("option redispatch")
23512350
}
23522351
d := &types.OptionRedispatch{
2353-
Interval: &br.Interval,
2352+
Interval: br.Interval,
23542353
NoOption: false,
23552354
}
23562355
if *br.Enabled == "disabled" {
23572356
d.NoOption = true
23582357
}
2359-
if br.Interval == 0 {
2360-
d = nil
2361-
}
23622358
if err := s.set("option redispatch", d); err != nil {
23632359
return err
23642360
}

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
@@ -9722,7 +9722,7 @@ definitions:
97229722
type: string
97239723
interval:
97249724
type: integer
9725-
x-nullable: false
9725+
x-nullable: true
97269726
required:
97279727
- enabled
97289728
type: object

specification/models/configuration/misc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ redispatch:
149149
enum: [enabled, disabled]
150150
interval:
151151
type: integer
152-
x-nullable: false
152+
x-nullable: true
153153
errorfile:
154154
type: object
155155
x-display-name: Error File

test/backend_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ func TestCreateEditDeleteBackend(t *testing.T) {
219219
Disabled: true,
220220
Redispatch: &models.Redispatch{
221221
Enabled: misc.StringP("enabled"),
222-
Interval: 0,
222+
Interval: misc.Int64P(0),
223223
},
224224
},
225225
}
@@ -236,9 +236,6 @@ func TestCreateEditDeleteBackend(t *testing.T) {
236236
t.Error(err.Error())
237237
}
238238

239-
// A redispatch with a zero interval is automatically removed from configuration.
240-
b.Redispatch = nil
241-
242239
var givenJSONB []byte
243240
givenJSONB, err = b.MarshalBinary()
244241
if err != nil {

0 commit comments

Comments
 (0)