fix(yaml): try int parsing before fallback

json and yaml returns 2 different types
float64 vs int
This commit is contained in:
lnu 2021-12-13 12:45:05 +01:00 committed by Jan De Dobbeleer
parent dc8db5dd25
commit fe3bab8e8a

View file

@ -89,12 +89,17 @@ func (p properties) getFloat64(property Property, defaultValue float64) float64
return defaultValue
}
floatValue, ok := val.(float64)
if floatValue, ok := val.(float64); ok {
return floatValue
}
// config parser parses an int
intValue, ok := val.(int)
if !ok {
return defaultValue
}
return floatValue
return float64(intValue)
}
func (p properties) getInt(property Property, defaultValue int) int {
@ -107,7 +112,7 @@ func (p properties) getInt(property Property, defaultValue int) int {
return intValue
}
// json parses a float
// config parser parses a float
intValue, ok := val.(float64)
if !ok {
return defaultValue