'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 ?



Solution 1:[1]

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

Your template should be:

{{ div .Values.myvalue 2 }}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ozlevka