Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any substring function in helm chart yaml templates ?

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

like image 201
FreshMike Avatar asked Dec 03 '22 19:12

FreshMike


2 Answers

You can use the regexFind function in helm

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

Will get the text following the last /

like image 71
Curtis Allen Avatar answered Dec 28 '22 20:12

Curtis Allen


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.

like image 45
Ben T Avatar answered Dec 28 '22 20:12

Ben T