mirror of https://github.com/hashicorp/consul
simpler fix
parent
5db185a7e4
commit
aebb50d47d
|
@ -917,26 +917,27 @@ type HealthCheckDefinition struct {
|
||||||
DeregisterCriticalServiceAfter time.Duration `json:",omitempty"`
|
DeregisterCriticalServiceAfter time.Duration `json:",omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Alias HealthCheckDefinition
|
func (d *HealthCheckDefinition) MarshalJSON() ([]byte, error) {
|
||||||
type exportedHealthCheckDefinition struct {
|
type Alias HealthCheckDefinition
|
||||||
|
exported := &struct {
|
||||||
Interval string `json:",omitempty"`
|
Interval string `json:",omitempty"`
|
||||||
Timeout string `json:",omitempty"`
|
Timeout string `json:",omitempty"`
|
||||||
DeregisterCriticalServiceAfter string `json:",omitempty"`
|
DeregisterCriticalServiceAfter string `json:",omitempty"`
|
||||||
*Alias
|
*Alias
|
||||||
}
|
}{
|
||||||
|
Interval: d.Interval.String(),
|
||||||
func (d *HealthCheckDefinition) MarshalJSON() ([]byte, error) {
|
Timeout: d.Timeout.String(),
|
||||||
exported := &exportedHealthCheckDefinition{
|
DeregisterCriticalServiceAfter: d.DeregisterCriticalServiceAfter.String(),
|
||||||
Alias: (*Alias)(d),
|
Alias: (*Alias)(d),
|
||||||
}
|
}
|
||||||
if d.Interval != 0 {
|
if d.Interval == 0 {
|
||||||
exported.Interval = d.Interval.String()
|
exported.Interval = ""
|
||||||
}
|
}
|
||||||
if d.Timeout != 0 {
|
if d.Timeout == 0 {
|
||||||
exported.Timeout = d.Interval.String()
|
exported.Timeout = ""
|
||||||
}
|
}
|
||||||
if d.DeregisterCriticalServiceAfter != 0 {
|
if d.DeregisterCriticalServiceAfter == 0 {
|
||||||
exported.DeregisterCriticalServiceAfter = d.Interval.String()
|
exported.DeregisterCriticalServiceAfter = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
return json.Marshal(exported)
|
return json.Marshal(exported)
|
||||||
|
|
Loading…
Reference in New Issue