Syntax Error in Yaml File - missed comma between flow collection entries

1/19/2021

We have an application deployed in AKS , the kubernetes version we were using is 1.15 now we want to upgrade the Kubernetes to 1.16, I notice that some of the APIs have been deprecated in 1.16.We have deployment.yaml file in which I had to change the from

apiVersion: extensions/v1beta1 to apiVersion: apps/v1 for Deployment.

after doing this change I see that the deployment YAML is failing lint test for another entry :

    - name  : APP_HOST
    {{- range $host := .Values.ingress.hosts }}
      value: {{ $host }}
    {{- end }}

Error :

npx yaml-lint yamllint deployment.yaml

npx: installed 45 in 14.04s

× YAML Lint failed for deployment.yaml

× missed comma between flow collection entries at line 88, column 11: {{- range $host := .Values.ingress ...

Can some one help me with the syntax needed for this. Mind you it was working fine before. Not sure if I have added and extra space or corrupted the file.

Thanks

-- ptilloo
azure-aks
kubernetes
kubernetes-helm
syntax
yaml

1 Answer

1/19/2021

The syntax you have looks like a correct Helm template, including correct whitespace controls. However, it is not valid YAML; the template {{ ... }} syntax looks at least a little bit like an inline mapping { key: value }, and this confuses the linter.

You can't run the un-rendered Helm template files through yamllint or another plain YAML validator. You can run helm template to render the template to plain text, and then run yamllint on that. The current version of Helm will try to parse the produced YAML as it generates it, so just running helm template will give you some protection against whitespace errors.

-- David Maze
Source: StackOverflow