helmfile/helmfile

Rendered Array Error

Closed this issue · 1 comments

Operating system

Sonoma 14.4

Helmfile Version

v0.162.0

Helm Version

v3.14.2

Bug description

I am using a helm template like this:

source:
    {{- range .Values.source }}
    {{- if .repoURL }}
    - repoURL: {{ .repoURL }}
      {{- if .chart }}
      chart: {{ .chart }}
      {{- end }}
      targetRevision: {{ .targetRevision }}
      {{- if .helm }}
      helm:
        {{- if .helm.parameters }}
        parameters:
          {{- range .helm.parameters }}
          {{- range $key, $value := . }}
          - name: {{ $key }}
            value: {{ $value | quote }}
          {{- end }}
          {{- end }}
        {{- end }}
        {{- if .helm.file }}
        values: |-
          {{- .helm.file | nindent 8 }}
        {{- end }}
        {{- if .helm.valuefiles }}
        valueFiles:
          {{- range .helm.valuefiles }}
          - {{ . }}
          {{- end }}
        {{- end }}
      {{- end }}
      {{- if .path }}
      path: {{ .path }}
      {{- end }}
      {{- if .ref }}
      ref: {{ .ref }}
      {{- end }}
      {{- if .kustomize }}
      kustomize:
        {{- if .kustomize.namePrefix}}
        namePrefix: {{ .kustomize.namePrefix }}
        {{- end }}
        {{- if .kustomize.nameSuffix}}
        nameSuffix: {{ .kustomize.nameSuffix }}
        {{- end }}
        {{- if .kustomize.images}}
        images: {{ .kustomize.images }}
        {{- end }}
      {{- end }}
    {{- end }}

When I rendered(helmfile diff) it looks like good:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: redis
  namespace: argocd
  labels:
    app: redis
    env: "dev"
    layer: "infra"
spec:
  destination:
    namespace: redis
    server: https://kubernetes.default.svc
  source:
    - repoURL: https://charts.bitnami.com/bitnami
      chart: redis
      targetRevision: 
      helm:
        valueFiles:
          - $values/infrastructure/argocd/helmfiles/westeurope/dev/redis/values.yaml
    - repoURL: github.com/me/demo
      targetRevision: main
      ref: values
  project: default
  syncPolicy:
    syncOptions:
      - PruneLast=true
      - CreateNamespace=true
      - ApplyOutOfSyncOnly=true
      - PrunePropagationPolicy=foreground
    automated:
      prune: true
      selfHeal: true

But when I try to apply it I get:

COMBINED OUTPUT:
  Release "redis" does not exist. Installing it now.
  coalesce.go:237: warning: skipped value for argocd-apps.source: Not a table.
  W0526 19:16:22.116624   18792 warnings.go:70] unknown field "spec.source[0].chart"
  W0526 19:16:22.116653   18792 warnings.go:70] unknown field "spec.source[0].helm"
  W0526 19:16:22.116658   18792 warnings.go:70] unknown field "spec.source[0].repoURL"
  W0526 19:16:22.116662   18792 warnings.go:70] unknown field "spec.source[0].targetRevision"
  W0526 19:16:22.116665   18792 warnings.go:70] unknown field "spec.source[1].ref"
  W0526 19:16:22.116668   18792 warnings.go:70] unknown field "spec.source[1].repoURL"
  W0526 19:16:22.116672   18792 warnings.go:70] unknown field "spec.source[1].targetRevision"

Example helmfile.yaml

---
templates:
  argocd-apps: &argocd-apps
    chart: helm-charts/argocd-apps
    version: 0.0.1

  - name: redis
    <<: *argocd-apps
    namespace: redis
    createNamespace: true
    disableValidation: true
    labels:
      release-name: "{{ `{{ .Release.Name }}` }}"
      layer: "infra"
    setTemplate:
      - name: source.0.repoURL
        value: "https://charts.bitnami.com/bitnami"
      - name: source.0.chart
        value: 'redis'
      - name: source.1.targetRevision
        value: 19.1.0
      - name: source.0.helm.valuefiles
        values:
          - "$values/infrastructure/argocd/helmfiles/{{ `{{ requiredEnv \"az_region\" }}` }}/{{ .Environment.Name }}/redis/values.yaml"
      - name: source.1.repoURL
        value: "github.com/me/demo"
      - name: source.1.targetRevision
        value: "main"
      - name: source.1.ref
        value: "values"

Error message you've seen (if any)

COMBINED OUTPUT:
  Release "redis" does not exist. Installing it now.
  coalesce.go:237: warning: skipped value for argocd-apps.source: Not a table.
  W0526 19:16:22.116624   18792 warnings.go:70] unknown field "spec.source[0].chart"
  W0526 19:16:22.116653   18792 warnings.go:70] unknown field "spec.source[0].helm"
  W0526 19:16:22.116658   18792 warnings.go:70] unknown field "spec.source[0].repoURL"
  W0526 19:16:22.116662   18792 warnings.go:70] unknown field "spec.source[0].targetRevision"
  W0526 19:16:22.116665   18792 warnings.go:70] unknown field "spec.source[1].ref"
  W0526 19:16:22.116668   18792 warnings.go:70] unknown field "spec.source[1].repoURL"
  W0526 19:16:22.116672   18792 warnings.go:70] unknown field "spec.source[1].targetRevision"

Steps to reproduce

try render an array from template

Working Helmfile Version

v0.162.0

Relevant discussion

No response

Was my fault. Was a typo.