FreshMike
FreshMike

Reputation: 551

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 ?

Upvotes: 7

Views: 20291

Answers (3)

Ben T
Ben T

Reputation: 4946

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.

Upvotes: 5

Curtis Allen
Curtis Allen

Reputation: 873

You can use the regexFind function in helm

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

Will get the text following the last /

Upvotes: 15

Marcin Romaszewicz
Marcin Romaszewicz

Reputation: 969

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.

Upvotes: 4

Related Questions