<p>I have a helm chart template, and I would like to use the result of <code>whoami</code> as a template variable. How do I do this?</p>

<p>So if my values.yaml file has: </p>

<pre><code>env:
  uniqueId: {{ whoami? }}
</code></pre>

<p>how might I do this?</p>

<p>note: I am on os x, so whoami I believe assumes a linux environment, however, in the spirit of this being deployment agnostic I presume there is a non-unix way of doing this.</p>

<p>The Helm Chart's "values.yaml" file is typically for default values. Anything that you'd like to override should be done at time of install/upgrade of the chart.</p>

<p>The Helm docs show a lot of different ways in which values can be used: <a href="https://github.com/kubernetes/helm/blob/master/docs/charts.md" rel="nofollow noreferrer">https://github.com/kubernetes/helm/blob/master/docs/charts.md</a></p>

<p>In this case, one option is to set the value on the command line:</p>

<pre><code>helm install -set env.whoami=$(id -un) ./your-chart.tgz
</code></pre>

<p>You could then have a value.yaml file like:</p>

<pre><code>env:
    whoami: "default"
</code></pre>

<p>Finally, you can use it in a template like:</p>

<pre><code>  containers:
  - name: {{ .Chart.Name }}
    image: "{{ .Values.image.repository }}:{{ .Chart.Version }}"
    imagePullPolicy: {{ .Values.image.pullPolicy }}
    env:
    - name: WHOAMI
      value: {{ .Values.env.whoami }}
</code></pre>

<p>Obviously your template will vary, the above is just a snippet.</p>
