<p>I am trying to loop for a count in a kubernetes helm chart like this:</p>

<pre><code>reaction.mongo_url_big: mongodb://{{ for $mongocount := 0; $mongocount &lt; {{ .Values.mongodbReplicantCount }}; $mongocount++ }}{{ .Values.mongodbReleaseName }}-mongodb-replicaset-{{ $mongocount }}:{{ .Values.mongodbPort }}{{ if $mongocount &lt; {{ .Values.mongodbReplicantCount }} - 1 }},{{ end }}{{ end }}/{{ .Values.mongodbName }}?replicaSet={{ .Values.mongodbReplicaSet }}
</code></pre>

<p>However, go templates seem to be lacking a means of rendering a 'for' loop, <a href="https://groups.google.com/forum/#!topic/golang-nuts/ahKwwz4fRFM" rel="nofollow noreferrer">by design</a></p>

<p>I want it to output something like:</p>

<pre><code> reaction.mongo_url: mongodb://{{ .Values.mongodbReleaseName }}-mongodb-replicaset-0:{{ .Values.mongodbPort }},{{ .Values.mongodbReleaseName }}-mongodb-replicaset-1:{{ .Values.mongodbPort }},{{ .Values.mongodbReleaseName }}-mongodb-replicaset-2:{{ .Values.mongodbPort }}/{{ .Values.mongodbName }}?replicaSet={{ .Values.mongodbReplicaSet }}
</code></pre>

<p>The line in my helm chart is here:
<a href="https://github.com/joshuacox/reactionetes/blob/gymongonasium/reactioncommerce/templates/configmap.yaml#L11" rel="nofollow noreferrer">https://github.com/joshuacox/reactionetes/blob/gymongonasium/reactioncommerce/templates/configmap.yaml#L11</a></p>

thoth
<p>Use range:</p>

<pre><code>{{ range .Values }}
   {{ .MongodbReleaseName }}
{{ end }}
</code></pre>

<p>This will output the .MongodbReleaseName (assuming that's a field) of every item in .Values. The value is assigned to . while within the range so you can simply refer to fields/functions of the individual Values. This is very like a for loop in other templating languages. You can also use it by assigning an index and value. </p>
