title: Encode integer in Helm template
body: <p>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:</p>
  
  <pre><code>0=A
  1=B
  2=C
  ...
  26=a
  ...
  63=_
  </code></pre>
  
  <p>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 <code>location</code> block. The actual encoding logic is something like (psuedo-code):</p>
  
  <pre><code>func Encode(int i) {
    byte b = i &lt;&lt; 2 # shift integer two bits
    string s = web_base64(b)
    char c = s[0] # return first char only
  }
  </code></pre>
  
  <p>So far the closest I've gotten in Helm is just creating a lookup, like <code>$d := dict "0" "A" "1" "B" "2" "C" ...</code> and then using <code>{{ .Values.Id | toString | get $d }}</code>.</p>
  
  <p>Is there another way? </p>