<p>How can I check if a variable is a boolean value &quot;true&quot; in helm chart?
I have in Values.yaml a parameter set as:</p>
<pre><code>myParameter: true
</code></pre>
<p>I don't understand well difference between:</p>
<pre><code>{{- if .Values.service.myParameter }}
</code></pre>
<p>and</p>
<pre><code>{{- if eq .Values.service.myParameter &quot;true&quot; }}
</code></pre>
<p>I want that flow goes in if clause if the parameter is set as boolean &quot;true&quot;</p>

Riccardo Califano
<p>The <a href="https://godoc.org/text/template" rel="noreferrer">documentation for the Go <code>text/template</code> package</a> explains what the <code>if</code> statement considers as &quot;true&quot;:</p>
<blockquote>
<p>The empty [&quot;false&quot;] values are false, 0, any nil pointer or interface value, and any array, slice, map, or string of length zero.</p>
</blockquote>
<p>YAML values are typed and the usual rules are that bare <code>true</code> and <code>false</code> are booleans:</p>
<pre class="lang-yaml prettyprint-override"><code>boolean: true
string: other text, but not &quot;true&quot;, &quot;false&quot;, or &quot;null&quot;
also a string: 'true'
</code></pre>
<p>In your examples:</p>
<pre><code>{{- if .Values.service.myParameter }}...{{ end }}
</code></pre>
<p>will evaluate to true whenever <code>myParameter</code> exists (isn't Go <code>nil</code>) and isn't zero, literal <code>false</code>, or an empty string.</p>
<pre><code>{{- if eq .Values.service.myParameter &quot;true&quot; }}...{{ end }}
</code></pre>
<p>will evaluate to true whenever <code>myParameter</code> is exactly the <em>string</em> <code>&quot;true&quot;</code>, but not a boolean <code>true</code>.  (I think you will get a type error from the template engine if it's a boolean, in fact.)</p>
