Skip to content

Helm lint fail on extraResources definition #420

Description

@ClementB-01

Hello,

When declaring extraResources with the chart in version 15.2.0, I'm coming across an error when running helm lint. This error only occur when passing values with -f flag as shown here :

$ helm lint
==> Linting .

1 chart(s) linted, 0 chart(s) failed
$ helm lint -f values.yaml
==> Linting .
[ERROR] templates/extra-resources.yaml: unable to parse YAML: invalid Yaml document separator: apiVersion: v1

Error: 1 chart(s) linted, 1 chart(s) failed

However there is no issue with helm template command.
The fact that helm lint and helm template behave in different ways seem linked to this : helm/helm#10149.

I've been able to find a workaround by declaring the values as string instead of yaml object :
Yaml object declaration :

extraResources:
  - apiVersion: v1
    [...]

String declaration :

extraResources:
  - |

    apiVersion: v1
    [...]

Upon further investigation it seem that the dash before tpl in templates/extra-resources.yaml is involved.
When modified like below, it seem to be valid for both type of declaration:

{{- if .Values.extraResources }}
{{- range .Values.extraResources }}
---
{{- if typeIs "string" . }}
{{ tpl . $ }}
{{- else }}
{{ tpl (toYaml .) $ }}
{{- end }}
{{- end }}
{{- end }}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions