mirror of
https://github.com/helm/charts.git
synced 2026-08-23 22:37:45 +00:00
Going along the readme for the common package, it's suggested many times
to use the templates with no values inside, for example:
```
{{- template "common.ingress" (list . "mychart.ingress") -}}
{{- define "mychart.ingress" -}}
{{- end -}}
```
This will give the following error:
```
Error: rendering template failed: assignment to entry in nil map
```
By adding empty dict defaults, we can fix the code and respect the README
Signed-off-by: Javier Domingo Cansino <javierdo1@gmail.com>
16 lines
490 B
Go
16 lines
490 B
Go
{{- /*
|
|
common.util.merge will merge two YAML templates and output the result.
|
|
|
|
This takes an array of three values:
|
|
- the top context
|
|
- the template name of the overrides (destination)
|
|
- the template name of the base (source)
|
|
|
|
*/ -}}
|
|
{{- define "common.util.merge" -}}
|
|
{{- $top := first . -}}
|
|
{{- $overrides := fromYaml (include (index . 1) $top) | default (dict ) -}}
|
|
{{- $tpl := fromYaml (include (index . 2) $top) | default (dict ) -}}
|
|
{{- toYaml (merge $overrides $tpl) -}}
|
|
{{- end -}}
|