Skip to content

Commit 41bc43d

Browse files
committed
BUG/MINOR: redispatch: allow interval of 0
1 parent f7b6b46 commit 41bc43d

File tree

7 files changed

+12
-19
lines changed

7 files changed

+12
-19
lines changed

configuration/backend_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ func TestCreateEditDeleteBackend(t *testing.T) {
827827
Disabled: true,
828828
Redispatch: &models.Redispatch{
829829
Enabled: misc.StringP("enabled"),
830-
Interval: 0,
830+
Interval: misc.Int64P(0),
831831
},
832832
}
833833

@@ -843,9 +843,6 @@ func TestCreateEditDeleteBackend(t *testing.T) {
843843
t.Error(err.Error())
844844
}
845845

846-
// A redispatch with a zero interval is automatically removed from configuration.
847-
b.Redispatch = nil
848-
849846
var givenJSONB []byte
850847
givenJSONB, err = b.MarshalBinary()
851848
if err != nil {

configuration/configuration.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -968,9 +968,8 @@ func (s *SectionParser) redispatch() interface{} {
968968
return nil
969969
}
970970
d := data.(*types.OptionRedispatch)
971-
br := &models.Redispatch{}
972-
if d.Interval != nil {
973-
br.Interval = *d.Interval
971+
br := &models.Redispatch{
972+
Interval: d.Interval,
974973
}
975974
if d.NoOption {
976975
d := "disabled"
@@ -2437,15 +2436,12 @@ func (s *SectionObject) redispatch(field reflect.Value) error {
24372436
return misc.CreateTypeAssertError("option redispatch")
24382437
}
24392438
d := &types.OptionRedispatch{
2440-
Interval: &br.Interval,
2439+
Interval: br.Interval,
24412440
NoOption: false,
24422441
}
24432442
if *br.Enabled == "disabled" {
24442443
d.NoOption = true
24452444
}
2446-
if br.Interval == 0 {
2447-
d = nil
2448-
}
24492445
if err := s.set("option redispatch", d); err != nil {
24502446
return err
24512447
}

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
@@ -9338,7 +9338,7 @@ definitions:
93389338
type: string
93399339
interval:
93409340
type: integer
9341-
x-nullable: false
9341+
x-nullable: true
93429342
required:
93439343
- enabled
93449344
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

0 commit comments

Comments
 (0)