Use Helm's `base` function to get folder name

Turns out Helm implements go template function ``base`` that will return
last component of a path. Instead of doing that manually in _funcs.tpl,
we can leverage the builtin. This commit replaces that.

Change-Id: I1b0c90e82790de405730b61ee85654a8810d6907
This commit is contained in:
Michał Dulko 2017-04-18 15:48:34 +02:00 committed by Michal Dulko
parent fb22abdb63
commit 8185104a5c

View File

@ -19,9 +19,7 @@
{{- define "helm-toolkit.template" -}} {{- define "helm-toolkit.template" -}}
{{- $name := index . 0 -}} {{- $name := index . 0 -}}
{{- $context := index . 1 -}} {{- $context := index . 1 -}}
{{- $v:= $context.Template.Name | split "/" -}} {{- $last := base $context.Template.Name }}
{{- $n := len $v -}}
{{- $last := sub $n 1 | printf "_%d" | index $v -}}
{{- $wtf := $context.Template.Name | replace $last $name -}} {{- $wtf := $context.Template.Name | replace $last $name -}}
{{ include $wtf $context }} {{ include $wtf $context }}
{{- end -}} {{- end -}}
@ -29,9 +27,7 @@
{{- define "helm-toolkit.hash" -}} {{- define "helm-toolkit.hash" -}}
{{- $name := index . 0 -}} {{- $name := index . 0 -}}
{{- $context := index . 1 -}} {{- $context := index . 1 -}}
{{- $v:= $context.Template.Name | split "/" -}} {{- $last := base $context.Template.Name }}
{{- $n := len $v -}}
{{- $last := sub $n 1 | printf "_%d" | index $v -}}
{{- $wtf := $context.Template.Name | replace $last $name -}} {{- $wtf := $context.Template.Name | replace $last $name -}}
{{- include $wtf $context | sha256sum | quote -}} {{- include $wtf $context | sha256sum | quote -}}
{{- end -}} {{- end -}}