<blockquote>
<p>How to append a list to another list inside a dictionary using Helm?</p>
</blockquote>
<p>I have a Helm chart specifying the key <code>helm</code> inside of an Argo CD <code>Application</code> (see snippet below).</p>
<p>Now given a <code>values.yaml</code> file, e.g.:</p>
<pre><code>helm:
  valueFiles:
  - myvalues1.yaml
  - myvalues2.yaml
</code></pre>
<p>I want to append <code>helm.valuesFiles</code> to the one below. How can I achieve this? The <a href="https://helm.sh/docs/chart_template_guide/function_list/#merge-mustmerge" rel="nofollow noreferrer">merge</a> function doesn't seem to satisfy my needs in this case, since precedence will be given to the first dictionary.</p>
<pre><code>apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: guestbook
  # You'll usually want to add your resources to the argocd namespace.
  namespace: argocd
  # Add this finalizer ONLY if you want these to cascade delete.
  finalizers:
    - resources-finalizer.argocd.argoproj.io
  # Add labels to your application object.
  labels:
    name: guestbook
spec:
  # The project the application belongs to.
  project: default

  # Source of the application manifests
  source:
    repoURL: https://github.com/argoproj/argocd-example-apps.git  # Can point to either a Helm chart repo or a git repo.
    targetRevision: HEAD  # For Helm, this refers to the chart version.
    path: guestbook  # This has no meaning for Helm charts pulled directly from a Helm repo instead of git.

    # helm specific config
    chart: chart-name  # Set this when pulling directly from a Helm repo. DO NOT set for git-hosted Helm charts.
    helm:
      passCredentials: false # If true then adds --pass-credentials to Helm commands to pass credentials to all domains
      # Extra parameters to set (same as setting through values.yaml, but these take precedence)
      parameters:
      - name: &quot;nginx-ingress.controller.service.annotations.external-dns\\.alpha\\.kubernetes\\.io/hostname&quot;
        value: mydomain.example.com
      - name: &quot;ingress.annotations.kubernetes\\.io/tls-acme&quot;
        value: &quot;true&quot;
        forceString: true # ensures that value is treated as a string

      # Use the contents of files as parameters (uses Helm's --set-file)
      fileParameters:
      - name: config
        path: files/config.json

      # Release name override (defaults to application name)
      releaseName: guestbook

      # Helm values files for overriding values in the helm chart
      # The path is relative to the spec.source.path directory defined above
      valueFiles:
      - values-prod.yaml
</code></pre>
<p><a href="https://raw.githubusercontent.com/argoproj/argo-cd/master/docs/operator-manual/application.yaml" rel="nofollow noreferrer">https://raw.githubusercontent.com/argoproj/argo-cd/master/docs/operator-manual/application.yaml</a></p>

Shuzheng
<p>If you only need to append <code>helm.valueFiles</code> to the existing <code>.spec.source.helm.valueFiles</code>, you can range through the list in the values file and add the list items like this:</p>
<pre><code>valueFiles:
  - values-prod.yaml
  {{- range $item := .Values.helm.valueFiles }}
  - {{ $item }}
  {{- end }}
</code></pre>
