title: If condition checking value returned by helm template
body: <p>I have a parent chart with 2 subcharts. The parent chart has global.myflag while the subcharts have myflag fields, in their respective values.yaml. I want the flexibility, where the sub-charts could be deployed independently. So, I have added a template function in the sub-chart _helper.tpl where I want to check 
  - if global.myflag exists, use that value
  - else use value of myflag from the subchart</p>
  
  <p>The template will return true/false. Something like this -</p>
  
  <pre><code>{{- define "isFlagEnabled" -}}
  {{- $flag := false -}}
  {{- if .Values.myflag -}}
  {{- $flag := .Values.myflag -}}
  {{- end -}}
  {{- if .Values.global.myflag -}}
  {{- $flag := .Values.global.myflag -}}
  {{- end -}}
  {{- printf "%s" $flag -}}
  {{- end -}}
  </code></pre>
  
  <p>And using this value (true/false), I want to set some values in my config.yaml. </p>
  
  <pre><code>{{- if eq (value from template) true -}}
  </code></pre>
  
  <p>I am having two questions here -
  1. Can we do 'if' condition on the template values? How?
  2. Is there a better way to do this?</p>