How to define my own helm template functions

8/8/2019

I need to provide a string in a helm template that is then sha256 encrypted and dumped out as a hexdigest, then pushed into a json structure.

Currently I have a values file like

Users: - userid: Santa passwd: Claus

and I'm defining a secret like

users.json: {{ .Values.Users | toJson | b64enc }}

but I want the passwd field encrypted as expected by the application. I'm not aware of any helper in helm that provides sha256 encryption so I'm wondering if I can supply my own, and then what the syntax would look like.

Help appreciated.

Thanks.

-- Michael Soulier
go
kubernetes-helm

1 Answer

8/10/2019

Helm exposes in it's templates most of the functions implemented in Sprig, which includes cryptographic functions as well - it includes sha256 as well.

(As a side note, sha256 is not an encryption algorithm, it's a hash function)

-- yanivoliver
Source: StackOverflow