Helm Chart: error converting YAML to JSON: yaml: mapping values are not allowed in this context

2.1k Views Asked by At

I am trying to install akv28s secrets using helm template but it fails, I am unable to diagnose the issue in helm, have tried online yaml validators but no help. Using --debug flags renders me the expected manifest

values.yaml

akv2k8s:
  enabled: true
  vaults:
    vaultcmms:
      secretkey: secretvalue
      secretkey1: secretvalue1
    vaulttenant:
      secretkey: secretvalue
      secretkey1: secretvalue2

akv28s.yaml

{{- if .Values.akv2k8s.enabled -}}
{{- range $vault, $content := .Values.akv2k8s.vaults }}
  {{- range $key, $value := $content }}
    apiVersion: spv.no/v2beta1
    kind: AzureKeyVaultSecret
    spec:
      vault: {{ $vault }}
        name: {{ $key}}
        object:
          name: {{ $value}}
          type: secret
    {{- end }}
    {{- end }}
    {{- end }}

1

There are 1 best solutions below

0
Usman Khawar On

I was making a mistake by specifying the vault value in the wrong hierarchy It should be like

spec:
  vault: 
    name: {{ $vault }}
    object:
      name: {{ $value }}
      type: secret

This solved my issue.