<p>I'm passing the following string through values.yaml:</p>
<pre><code>urls: http://example.com http://example2.com http://example3.com
</code></pre>
<p>Is there a way to create a list from this, so i can then do something like:</p>
<pre><code>{{ range $urls }}
{{ . }}
{{ end }}
</code></pre>
<p>The problem is I'm passing the urls var in a dynamic fashion, and I'm also can't avoid using a single string for that (ArgoCD ApplicationSet wont let me pass a list).</p>

Andres Julia
<p>Basically all you need is just add this line in your template <code>yaml</code>:</p>
<pre><code>{{- $urls := splitList &quot; &quot; .Values.urls }}
</code></pre>
<p>It will import <code>urls</code> string from <code>values.yaml</code> <a href="http://masterminds.github.io/sprig/string_slice.html" rel="nofollow noreferrer">as the list</a> so you will be able run your code which you posted in your question.</p>
<p><strong>Simple example based on <a href="https://helm.sh/docs/chart_template_guide/control_structures/" rel="nofollow noreferrer">helm docs</a></strong>:</p>
<ol>
<li><p>Let's get simple chart used in <a href="https://helm.sh/docs/chart_template_guide/getting_started/" rel="nofollow noreferrer">helm docs</a> and prepare it:</p>
<pre><code>helm create mychart
rm -rf mychart/templates/*
</code></pre>
</li>
<li><p>Edit <code>values.yaml</code> and insert <code>urls</code> string:</p>
<pre><code>urls: http://example.com http://example2.com http://example3.com
</code></pre>
</li>
<li><p>Create ConfigMap in <code>templates</code> folder (name it <code>configmap.yaml</code>)</p>
<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ .Release.Name }}-configmap
data:
  {{- $urls := splitList &quot; &quot; .Values.urls }}
  urls: |- 
    {{- range $urls }}
    - {{ . }}
    {{- end }}
</code></pre>
<p>As can see, I'm using your loop (with &quot;- &quot; to avoid creating empty lines).</p>
</li>
<li><p>Install chart and check it:</p>
<pre><code>helm install example ./mychart/
helm get manifest example
</code></pre>
<p>Output:</p>
<pre><code>---
# Source: mychart/templates/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: example-configmap
data:
  urls: |-
    - http://example.com
    - http://example2.com
    - http://example3.com
</code></pre>
</li>
</ol>
