templating: cast double to int
# 🌱|help-and-getting-started
b
Is there a way to cast a double to to an int...? My usecase is to properly size jvm heap..:
Copy code
yaml
# module..
variables:
  memory-mb: 512

# k8s manifest
env:
  - name: HEAP_OPTS
    value: "-Xms${(var.memory-mb * 0.9) / 2}m -Xmx${var.memory-mb * 0.9}m"
Unfortunately, jvm doesn't take doubles, it wants ints. The only way I could come up to solve this with the existing templating functions is this one:
split(string((var.memory-mb * 0.9) / 2), '.')[0]
->
Unable to parse as valid template string.
It doesn't work due to https://github.com/garden-io/garden/issues/3001. A
toInt
function would really come in handy here. Am I missing something?
q
@brief-dawn-88958 looking at https://docs.garden.io/using-garden/variables-and-templating and https://docs.garden.io/reference/template-strings/functions I don't see anything that supports casting to an int but I think this would make for a great feature request
I've updated the GH issue you mentioned with a link back here and a note you encountered the issue trying to work around a missing
toInt
function
4 Views