Helm Chart Template 'unable to parse YAML: error converting YAML to JSON: yaml: line 9: did not find expected key'

Viewed 32

I want multiple path under the paths property. However, I got this error 'unable to parse YAML: error converting YAML to JSON: yaml: line 9: did not find expected key' but I couldn't see what's wrong on line 9.

FYI line 9 and 10 are

paths:
{{- range $name, $svc := (default dict .Values.mappings) -}}

Here is the problematic template:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-auth
spec:
  rules:
  - host: {{ .Values.commonName }}
    http:
      paths:
      {{- range $name, $svc := (default dict .Values.mappings) -}}
      - path: {{ $svc.prefix }}
        pathType: Prefix
        backend:
          service:
            name: {{ $svc.name }}
            port:
              name: https
      {{- end -}}

And the values.yaml

commonName: {{ .Chart.Name }}
mappings:
  serviceA:
    prefix: /a/
    name: serviceA
  serviceB:
    prefix: /b/
    name: serviceB
0 Answers
Related