<p>Values.Yaml</p>
<pre><code>env:
  isTest: 'true'
  hostData:
  - isActive: true
    name: a
    url: testA
  - isActive: true
    name: A
    url: testB
</code></pre>
<p>configmap.yaml</p>
<pre><code>test:    
  {{- with .Values.env }}
  hostData: {{ .hostData | toJson}}
  isTest: {{ .isTest}}  
  {{- end }}
</code></pre>
<p>Now I want to update the url of hostData
I tried to add</p>
<pre><code>test:    
  {{- with .Values.env }}
  hostData: {{ .hostData | toJson}}
  isTest: {{ .isTest}}  
  {{- end }}
  {{- range .Values.env.hostData}}
  url: https://{{ .name}}//newName
  {{- end }}
</code></pre>
<p>But it add the url to the structure of the test</p>
<pre><code>test:
  hostData: [{&quot;isActive&quot;:true,&quot;name&quot;:A&quot;,&quot;url&quot;:&quot;testA&quot;},{&quot;isActive&quot;:true,&quot;name&quot;:&quot;B&quot;,&quot;url&quot;:&quot;testB&quot;}
  url AnewName
  url BnewName
</code></pre>
<p>and didn't update the hostData-&gt; url
This is the resuLT I want</p>
<pre><code>test:
   hostData: [{&quot;isActive&quot;:true,&quot;name&quot;:AnewName&quot;,&quot;url&quot;:&quot;testA&quot;},{&quot;isActive&quot;:true,&quot;name&quot;:&quot;BnewName&quot;,&quot;url&quot;:&quot;testB&quot;}]
</code></pre>
<p>I tried to create also tpl file and added my logic but the problem that I didn't succeed to return yaml from the tpl</p>
<pre><code>{{/*
Create hostData
*/}}
{{- define &quot;get-hostData&quot; -}}
{{- range .Values.env.hostData}}
hostData:
  - isActive: {{ .isActive }}
    name: {{ .name }}
    url: {{ newUrlFromValues }}
{{- end }}
</code></pre>
<p>The problem that in the config it didn`t return yaml but string</p>
<p>{{- $test1 := include &quot;get-hostData&quot; . }}</p>
<p>maybe I need to return it as json array</p>

<p>It's not entirely clear to me what you want to achieve. I assume your goal is to construct the <code>url</code> field from the <code>name</code> field (although in the provided example you are altering the <code>name</code> instead of the <code>url</code> (?)). You can do it by updating the <code>hostData</code> before converting it to JSON:</p>
<pre class="lang-yaml prettyprint-override"><code>test: 
  {{- with .Values.env }}
  {{- range .hostData}}
    {{- $url := print &quot;https://&quot; .name &quot;/newName&quot; }}
    {{- $_ := set . &quot;url&quot; $url }}
  {{- end }}   
  hostData: {{ .hostData | toJson }}
  isTest: {{ .isTest }}  
  {{- end }}
</code></pre>
