Files
chart/library/common/templates/helpers/_makeIntOrNoop.tpl
Stavros Kois 087d5be7cc NAS-122681 / 23.10 / Handle longer ints in few places that might have one (#1358)
* Handle longer ints in few places that might have one

* add tests

* add note

* Add some more checking
2023-07-15 23:14:46 +03:00

24 lines
644 B
Smarty

{{- define "ix.v1.common.helper.makeIntOrNoop" -}}
{{- $value := . -}}
{{/*
Ints in Helm can be either int, int64 or float64.
Values that start with zero should not be converted
to int again as this will strip leading zeros.
Numbers converted to E notation by Helm will
always contain the "e" character. So we only
convert those.
*/}}
{{- if and
(mustHas (kindOf $value) (list "int" "int64" "float64"))
(not (hasPrefix "0" ($value | toString)))
(contains "e" ($value | toString | lower))
-}}
{{- $value | int -}}
{{- else -}}
{{- $value -}}
{{- end -}}
{{- end -}}