The issue is that your Helm template is looking for YAML files in the files/ directory, but Helm has specific requirements for how files are accessed and processed.
Here are the most likely causes and solutions:
1. File Location Issue
Make sure your files/kijiji.ca.yaml is in the correct location relative to your Helm chart root. The .Files.Glob function looks for files relative to the chart's root directory.
Your structure should be:
your-chart/
├── Chart.yaml
├── values.yaml
├── templates/
│ └── syntheticcheck.yaml
└── files/
└── kijiji.ca.yaml
2. YAML Parsing Issue
The fromYamlArray function expects the content to be a YAML array or multiple documents. Try using fromYaml instead, or handle multiple documents differently:
{{- $files := .Files.Glob "files/*.yaml" }}
{{- range $path, $bytes := $files }}
{{- $content := $bytes | toString }}
{{- $docs := splitList "---" $content }}
{{- range $doc := $docs }}
{{- if $doc }}
{{- $obj := fromYaml $doc }}
{{- if and $obj (kindIs "map" $obj) }}
---
apiVersion: {{ $obj.apiVersion }}
kind: {{ $obj.kind }}
metadata:
name: {{ $obj.metadata.name }}
labels:
{{- toYaml $obj.metadata.labels | nindent 4 }}
spec:
{{ toYaml $obj.spec | nindent 2 }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
3. Debug the File Loading
Add some debug output to see what's happening:
{{- $files := .Files.Glob "files/*.yaml" }}
{{- range $path, $bytes := $files }}
# Debug: Processing file {{ $path }}
# Debug: Content length {{ len $bytes }}
{{- end }}
4. Alternative Approach
If the above doesn't work, try a simpler approach by putting the YAML content directly in values.yaml or using a different file processing method:
{{- range $path, $bytes := .Files.Glob "files/*.yaml" }}
{{ $bytes }}
{{- end }}
Run helm template with the debug flag to see what's being processed:
helm template --debug -f values.yaml .
Which of these approaches resolves the issue for you?