<p>I'm reading helm documentation,</p>
<blockquote>
<p>The templates/ directory is for template files. When Tiller evaluates a chart, it will send all of the files in the templates/ directory through the template rendering engine. Tiller then collects the results of those templates and sends them on to Kubernetes.</p>
</blockquote>
<p>I have lots of different templates in my template folder, I'm looking for a way to skip those templates that start with &quot;y&quot; and &quot;z&quot; and don't send it to Kubernetes, is there any way I can achieve that? I want to be flexible let's say if statementProvider is x, skip all manifests starting with y and z and do not send it to Kubernetes.</p>
<p>I wrote this helper function to extract the list of resources that should be deployed in Kubernetes but I don't know how I can use it:</p>
<pre><code>{{- define &quot;statement.resource&quot;}}
{{- $statementProvider := lower ( $.Values.statementProvider ) -}}
{{- $statementFiles := list -}}
{{- range $path, $bytes := .Files.Glob &quot;templates/**&quot; }}
    {{- if eq $statementProvider &quot;x&quot; -}}
        {{- if not (or (hasPrefix $path &quot;y&quot;) (hasPrefix $path &quot;z&quot;)) -}}
        {{- $statementFiles = append $statementFiles $path -}}
        {{- end }}
        {{- $statementFiles -}}
    {{- end }}

{{- end }}
{{- end }}
</code></pre>

someone
<p>What I'm gonna suggest is along the lines of what Michał has already done, but with a small tweak that might work for you.</p>
<p>So, your <code>template</code> can look something like this:</p>
<pre><code>{{- if .Values.apply_template.true }}
...
{{- end }}
</code></pre>
<p>and add this to your <code>values.yaml</code>:</p>
<pre><code>apply_template:
  true: true
  false: false
</code></pre>
<p>Now, as you mentioned: &quot;to skip those templates that start with &quot;y&quot; and &quot;z&quot;&quot;, you can run this simple <code>cmd</code> that would replace <code>true</code> with <code>false</code> in the templates that start with <code>y</code> and <code>z</code>.</p>
<pre><code>find . -type f \( -name &quot;y*.yaml&quot; -o -name &quot;z*.yaml&quot; \) -print0 | xargs -0 sed -i '' &quot;s/true/false/g&quot; | helm template .
</code></pre>
<p>You will still have to change your templates (one time) to add the <code>if</code> statement, but beyond that, you can control which templates you wanna skip going forward. I have only very quickly tested this on a couple of temp templates (and it works fine), but I hope this gives you some headway to achieve what you wanna do.</p>
<p>You might have to tweak the <code>cmd</code> a bit given that I'm running it on OSX - in case you are not (I guess you might have to git rid of the single quotes <code>''</code>.</p>
