4
votes

How can I substring a string like /com/app1/main to get the value of main in a HELM template ?

3

3 Answers

10
votes

You can use the regexFind function in helm

regexFind "[^/]+$" "/com/app1/main"

Will get the text following the last /

3
votes

Helm uses the sprig library to provide lots of data manipulation functions, have a look at their docs. You can use the {{ base }} function to do what you want.

3
votes

The sprig library that Helm uses provides a substr function to return a sub-string.

Some other useful functions are trunc (truncate), trim and regexFind.