title: helm templating with toYaml
body: <p>I have values.yml file that takes in a list of ports with this format and default values:</p>
  
  <pre><code>Ports:
    - number: 443
      protocol: http
  </code></pre>
  
  <p>The script that output the list of port to use as my input gives me this format:</p>
  
  <p><code>port_list=$(./get_ports.sh)</code></p>
  
  <p>output:</p>
  
  <pre><code>- 80
  - 8080
  </code></pre>
  
  <p>I want the resulting rendered template to be </p>
  
  <pre><code>Ports:
    - number: 80
    - number: 8080
  </code></pre>
  
  <p>How would I accomplish this? I tried the following in my template file:               </p>
  
  <pre><code>{{- with .Values.Ports }}
  Ports:
    {{- toYaml . | nindent 8 }}
  {{- end }}
  </code></pre>
  
  <p>using helm template and setting <code>values.Ports=$port_list</code>, it ended up giving me a pipe and an extra dash like below, which I do not know where they come from, how do I accomplish getting to the format I want above based on the input?</p>
  
  <pre><code>Ports:
  |-
    - number: 80
    - number: 8080
  </code></pre>
  
  <p>As a bonus, I would also like to have a default protocol in my port list when the protocol isn't specified.</p>
  
  <pre><code>Ports:
    - number: 80
      protocol: http
    - number: 8080
      protocol: http
  </code></pre>
  
  <p>Is there a clean way to do this with just templating?</p>