Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Helm template arithmetic division

Anyone tried to make an arithmetic division in Helm?

According to sprig/Math Functions, the following should work:

{{ .Values.myvalue | div 2 }}

However, the result is wrong. e.g. 6/2 = 0, 4/2 = 0, 1/2 = 2.

Any hint ?

like image 297
azalon Avatar asked Mar 07 '19 09:03

azalon


People also ask

Is Helm being deprecated?

On November 13th, 2020 the Stable and Incubator Helm chart repositories will be deprecated and all Helm-related images will no longer be available from GCR.

What is $_ in Helm?

The $_ is used to suppress undesired output as "set" returns the new dictionary.

What is trunc 63 in Helm?

trunc 63 truncates it to 63 characters in length.

What is Nindent?

nindent. The nindent function is the same as the indent function, but prepends a new line to the beginning of the string. nindent 4 $lots_of_text. The above will indent every line of text by 4 space characters and add a new line to the beginning.


1 Answers

You use the function the wrong way: See function declaration.

Your template should be:

{{ div .Values.myvalue 2 }}
like image 71
ozlevka Avatar answered Sep 21 '22 09:09

ozlevka