mirror of https://github.com/status-im/consul.git
only set default on H2PingUseTLS if H2PING is set
This commit is contained in:
parent
c5479cefe6
commit
ecdcfd6360
|
@ -1541,6 +1541,13 @@ func (b *builder) checkVal(v *CheckDefinition) *structs.CheckDefinition {
|
|||
return nil
|
||||
}
|
||||
|
||||
var H2PingUseTLSVal bool
|
||||
if stringVal(v.H2PING) != "" {
|
||||
H2PingUseTLSVal = boolValWithDefault(v.H2PingUseTLS, true)
|
||||
} else {
|
||||
H2PingUseTLSVal = boolVal(v.H2PingUseTLS)
|
||||
}
|
||||
|
||||
id := types.CheckID(stringVal(v.ID))
|
||||
|
||||
return &structs.CheckDefinition{
|
||||
|
@ -1571,7 +1578,7 @@ func (b *builder) checkVal(v *CheckDefinition) *structs.CheckDefinition {
|
|||
FailuresBeforeCritical: intVal(v.FailuresBeforeCritical),
|
||||
FailuresBeforeWarning: intValWithDefault(v.FailuresBeforeWarning, intVal(v.FailuresBeforeCritical)),
|
||||
H2PING: stringVal(v.H2PING),
|
||||
H2PingUseTLS: boolValWithDefault(v.H2PingUseTLS, true),
|
||||
H2PingUseTLS: H2PingUseTLSVal,
|
||||
DeregisterCriticalServiceAfter: b.durationVal(fmt.Sprintf("check[%s].deregister_critical_service_after", id), v.DeregisterCriticalServiceAfter),
|
||||
OutputMaxSize: intValWithDefault(v.OutputMaxSize, checks.DefaultBufSize),
|
||||
EnterpriseMeta: v.EnterpriseMeta.ToStructs(),
|
||||
|
|
|
@ -5638,7 +5638,6 @@ func TestLoad_FullConfig(t *testing.T) {
|
|||
Timeout: 4868 * time.Second,
|
||||
TTL: 11222 * time.Second,
|
||||
DeregisterCriticalServiceAfter: 68482 * time.Second,
|
||||
H2PingUseTLS: true,
|
||||
},
|
||||
},
|
||||
Connect: &structs.ServiceConnect{},
|
||||
|
|
|
@ -729,7 +729,7 @@ var translateH2PingUseTLS = []translateKeyTestCase{
|
|||
desc: "H2PingUseTLS: neither set",
|
||||
in: []interface{}{},
|
||||
want: true, // zero value
|
||||
jsonFmtStr: "{}",
|
||||
jsonFmtStr: "{" + `"h2ping":"testing"` + "}",
|
||||
equalityFn: h2pingUseTLSEqFn,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ func (t *CheckDefinition) UnmarshalJSON(data []byte) (err error) {
|
|||
}{
|
||||
Alias: (*Alias)(t),
|
||||
}
|
||||
|
||||
// Set default values
|
||||
aux.H2PingUseTLS = true
|
||||
aux.H2PingUseTLSSnake = true
|
||||
if err = lib.UnmarshalJSON(data, &aux); err != nil {
|
||||
|
@ -111,6 +111,11 @@ func (t *CheckDefinition) UnmarshalJSON(data []byte) (err error) {
|
|||
if !aux.H2PingUseTLSSnake {
|
||||
t.H2PingUseTLS = aux.H2PingUseTLSSnake
|
||||
}
|
||||
// unset default values if it is not an H2Ping check
|
||||
if t.H2PING == "" {
|
||||
aux.H2PingUseTLS = false
|
||||
aux.H2PingUseTLSSnake = false
|
||||
}
|
||||
|
||||
// Parse special values
|
||||
if aux.Interval != nil {
|
||||
|
|
|
@ -93,8 +93,10 @@ func (t *CheckType) UnmarshalJSON(data []byte) (err error) {
|
|||
}{
|
||||
Alias: (*Alias)(t),
|
||||
}
|
||||
// set default values
|
||||
aux.H2PingUseTLS = true
|
||||
aux.H2PingUseTLSSnake = true
|
||||
|
||||
if err = lib.UnmarshalJSON(data, aux); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -162,6 +164,11 @@ func (t *CheckType) UnmarshalJSON(data []byte) (err error) {
|
|||
if !aux.H2PingUseTLSSnake {
|
||||
t.H2PingUseTLS = aux.H2PingUseTLSSnake
|
||||
}
|
||||
// unset default values if it is not an H2Ping check
|
||||
if t.H2PING == "" {
|
||||
aux.H2PingUseTLS = false
|
||||
aux.H2PingUseTLSSnake = false
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
|
|
Loading…
Reference in New Issue