mirror of https://github.com/status-im/consul.git
fix marshalling
This commit is contained in:
parent
d4790b2827
commit
7f44100101
|
@ -917,27 +917,26 @@ type HealthCheckDefinition struct {
|
||||||
DeregisterCriticalServiceAfter time.Duration `json:",omitempty"`
|
DeregisterCriticalServiceAfter time.Duration `json:",omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *HealthCheckDefinition) MarshalJSON() ([]byte, error) {
|
type Alias HealthCheckDefinition
|
||||||
type Alias HealthCheckDefinition
|
type ExportedHealthCheckDefinition struct {
|
||||||
exported := &struct {
|
Interval string `json:",omitempty"`
|
||||||
Interval string
|
Timeout string `json:",omitempty"`
|
||||||
Timeout string
|
DeregisterCriticalServiceAfter string `json:",omitempty"`
|
||||||
DeregisterCriticalServiceAfter string
|
|
||||||
*Alias
|
*Alias
|
||||||
}{
|
}
|
||||||
Interval: d.Interval.String(),
|
|
||||||
Timeout: d.Timeout.String(),
|
func (d *HealthCheckDefinition) MarshalJSON() ([]byte, error) {
|
||||||
DeregisterCriticalServiceAfter: d.DeregisterCriticalServiceAfter.String(),
|
exported := &ExportedHealthCheckDefinition{
|
||||||
Alias: (*Alias)(d),
|
Alias: (*Alias)(d),
|
||||||
}
|
}
|
||||||
if d.Interval == 0 {
|
if d.Interval != 0 {
|
||||||
exported.Interval = ""
|
exported.Interval = d.Interval.String()
|
||||||
}
|
}
|
||||||
if d.Timeout == 0 {
|
if d.Timeout != 0 {
|
||||||
exported.Timeout = ""
|
exported.Timeout = d.Interval.String()
|
||||||
}
|
}
|
||||||
if d.DeregisterCriticalServiceAfter == 0 {
|
if d.DeregisterCriticalServiceAfter != 0 {
|
||||||
exported.DeregisterCriticalServiceAfter = ""
|
exported.DeregisterCriticalServiceAfter = d.Interval.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
return json.Marshal(exported)
|
return json.Marshal(exported)
|
||||||
|
|
Loading…
Reference in New Issue