From 8185104a5c35d20307356ba399bd60c094174091 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Dulko?= Date: Tue, 18 Apr 2017 15:48:34 +0200 Subject: [PATCH] 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 --- helm-toolkit/templates/_funcs.tpl | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/helm-toolkit/templates/_funcs.tpl b/helm-toolkit/templates/_funcs.tpl index 85059c4c54..38c39cf1df 100644 --- a/helm-toolkit/templates/_funcs.tpl +++ b/helm-toolkit/templates/_funcs.tpl @@ -19,9 +19,7 @@ {{- define "helm-toolkit.template" -}} {{- $name := index . 0 -}} {{- $context := index . 1 -}} -{{- $v:= $context.Template.Name | split "/" -}} -{{- $n := len $v -}} -{{- $last := sub $n 1 | printf "_%d" | index $v -}} +{{- $last := base $context.Template.Name }} {{- $wtf := $context.Template.Name | replace $last $name -}} {{ include $wtf $context }} {{- end -}} @@ -29,9 +27,7 @@ {{- define "helm-toolkit.hash" -}} {{- $name := index . 0 -}} {{- $context := index . 1 -}} -{{- $v:= $context.Template.Name | split "/" -}} -{{- $n := len $v -}} -{{- $last := sub $n 1 | printf "_%d" | index $v -}} +{{- $last := base $context.Template.Name }} {{- $wtf := $context.Template.Name | replace $last $name -}} {{- include $wtf $context | sha256sum | quote -}} {{- end -}}