title: Helm template - how to use "if exists at least one of" in array?
body: <p>I'm trying to make a list of env vars from a values.yaml become a single secret.yaml file containing the list of envs of the type "secret". The idea is to only create this secret file if at least one of the types equals "secret".</p>
  
  <p>Eg:</p>
  
  <p>values.yaml</p>
  
  <pre><code>env:
    - name: PLAIN_TEXT_ENV_VAR1
      type: plain
      value: text value
    - name: PLAIN_TEXT_ENV_VAR2
      type: plain
      value: text value
    - name: TOP_SECRET_ENV_VAR_1
      type: secret
    - name: TOP_SECRET_ENV_VAR_2
      type: secret
    - name: TOP_SECRET_ENV_VAR_3
      type: secret
  </code></pre>
  
  <p>resulting secret.yaml</p>
  
  <pre><code>kind: Secret
  metadata:
    name: test
  data:
      TOP_SECRET_ENV_VAR_1: change_me
      TOP_SECRET_ENV_VAR_2: change_me
      TOP_SECRET_ENV_VAR_3: change_me
  </code></pre>
  
  <p>I've already tried to create some flow control using range to iterate, boolean variables and if statements, but go template seems to ignore my ifs after I change it to another value.
  Now my secret template is like the one below.</p>
  
  <pre><code>{{ $flowcontrol := true -}}
  {{ if $flowcontrol -}}
  {{ range $env := $.Values.env -}}
  {{ if eq $env.type "secret" -}}
  apiVersion: v1
  kind: Secret
  metadata:
    name: testsecret
  data:
      {{- range $env := $.Values.env }}
          {{- if eq $env.type "secret" }}
      {{ $env.name }}: "change_me" 
          {{- end }}
      {{- end }}
  {{ $flowcontrol := false }}
  {{ end -}}
  {{ end -}}
  {{ end -}}
  
  </code></pre>
  
  <p>It results in three replicated secret.yaml files with 3 variables:</p>
  
  <pre><code>$ helm template . 
  ---
  # Source: teste/templates/secret.yaml
  apiVersion: v1
  kind: Secret
  metadata:
    name: testsecret
  data:
      TOP_SECRET_ENV_VAR_1: "change_me"
      TOP_SECRET_ENV_VAR_2: "change_me"
      TOP_SECRET_ENV_VAR_3: "change_me"
  
  apiVersion: v1
  kind: Secret
  metadata:
    name: testsecret
  data:
      TOP_SECRET_ENV_VAR_1: "change_me"
      TOP_SECRET_ENV_VAR_2: "change_me"
      TOP_SECRET_ENV_VAR_3: "change_me"
  
  apiVersion: v1
  kind: Secret
  metadata:
    name: testsecret
  data:
      TOP_SECRET_ENV_VAR_1: "change_me"
      TOP_SECRET_ENV_VAR_2: "change_me"
      TOP_SECRET_ENV_VAR_3: "change_me"
  
  </code></pre>
  
  <p>How can one control the flow as: if the first one item of a list satisfies the condition, iterate through the rest of the same list only in another section after?</p>