Skip to content

Commit

Permalink
lowercase string and simplify logic
Browse files Browse the repository at this point in the history
Co-authored-by: Manuel Rüger <manuel@rueg.eu>
  • Loading branch information
jabdoa2 and mrueg committed Jan 26, 2023
1 parent 2b5460f commit e26d682
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/customresourcestate/registry_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -635,10 +635,11 @@ func toFloat64(value interface{}, nilIsZero bool) (float64, error) {
}
return 0, nil
case string:
if value.(string) == "True" || value.(string) == "true" || value.(string) == "Yes" || value.(string) == "yes" {
normalized := strings.ToLower(value.(string))
if normalized == "true" || normalized == "yes" {
return 1, nil
}
if value.(string) == "False" || value.(string) == "false" || value.(string) == "No" || value.(string) == "no" {
if normalized == "false" || normalized == "no" {
return 0, nil
}
if t, e := time.Parse(time.RFC3339, value.(string)); e == nil {
Expand Down

0 comments on commit e26d682

Please sign in to comment.