I am working on a set of Helm templates for a web service, which takes as part of it's configuration an integer Id. That Id becomes part of the service endpoints, encoded to a web-safe base64 character set:
0=A
1=B
2=C
...
26=a
...
63=_
Within my Helm template I want to take that integer Id and determine the encoded value, so that I can insert it in an Nginx location
block. The actual encoding logic is something like (psuedo-code):
func Encode(int i) {
byte b = i << 2 # shift integer two bits
string s = web_base64(b)
char c = s[0] # return first char only
}
So far the closest I've gotten in Helm is just creating a lookup, like $d := dict "0" "A" "1" "B" "2" "C" ...
and then using {{ .Values.Id | toString | get $d }}
.
Is there another way?