_makeIntOrNoop.tpl 644 B

1234567891011121314151617181920212223
  1. {{- define "ix.v1.common.helper.makeIntOrNoop" -}}
  2. {{- $value := . -}}
  3. {{/*
  4. Ints in Helm can be either int, int64 or float64.
  5. Values that start with zero should not be converted
  6. to int again as this will strip leading zeros.
  7. Numbers converted to E notation by Helm will
  8. always contain the "e" character. So we only
  9. convert those.
  10. */}}
  11. {{- if and
  12. (mustHas (kindOf $value) (list "int" "int64" "float64"))
  13. (not (hasPrefix "0" ($value | toString)))
  14. (contains "e" ($value | toString | lower))
  15. -}}
  16. {{- $value | int -}}
  17. {{- else -}}
  18. {{- $value -}}
  19. {{- end -}}
  20. {{- end -}}