From c38fb120bf16fb8e6303bf1832aac85fae8389d4 Mon Sep 17 00:00:00 2001 From: John Hofman Date: Mon, 5 Dec 2016 10:01:25 +0100 Subject: [PATCH] fix(helm): add trimSuffix to helper functions --- docs/examples/nginx/templates/_helpers.tpl | 4 ++-- pkg/chartutil/create.go | 4 ++-- pkg/lint/rules/testdata/albatross/templates/_helpers.tpl | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/examples/nginx/templates/_helpers.tpl b/docs/examples/nginx/templates/_helpers.tpl index 200aee93a..11d18431d 100644 --- a/docs/examples/nginx/templates/_helpers.tpl +++ b/docs/examples/nginx/templates/_helpers.tpl @@ -2,7 +2,7 @@ {{/* Expand the name of the chart. */}} -{{define "name"}}{{default "nginx" .Values.nameOverride | trunc 24 }}{{end}} +{{define "name"}}{{default "nginx" .Values.nameOverride | trunc 24 | trimSuffix "-" }}{{end}} {{/* Create a default fully qualified app name. @@ -12,5 +12,5 @@ We truncate at 24 chars because some Kubernetes name fields are limited to this */}} {{define "fullname"}} {{- $name := default "nginx" .Values.nameOverride -}} -{{printf "%s-%s" .Release.Name $name | trunc 24 -}} +{{printf "%s-%s" .Release.Name $name | trunc 24 | trimSuffix "-" -}} {{end}} diff --git a/pkg/chartutil/create.go b/pkg/chartutil/create.go index 406e93de2..f4f83cc75 100644 --- a/pkg/chartutil/create.go +++ b/pkg/chartutil/create.go @@ -162,7 +162,7 @@ const defaultHelpers = `{{/* vim: set filetype=mustache: */}} Expand the name of the chart. */}} {{- define "name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 24 -}} +{{- default .Chart.Name .Values.nameOverride | trunc 24 | trimSuffix "-" -}} {{- end -}} {{/* @@ -171,7 +171,7 @@ We truncate at 24 chars because some Kubernetes name fields are limited to this */}} {{- define "fullname" -}} {{- $name := default .Chart.Name .Values.nameOverride -}} -{{- printf "%s-%s" .Release.Name $name | trunc 24 -}} +{{- printf "%s-%s" .Release.Name $name | trunc 24 | trimSuffix "-" -}} {{- end -}} ` diff --git a/pkg/lint/rules/testdata/albatross/templates/_helpers.tpl b/pkg/lint/rules/testdata/albatross/templates/_helpers.tpl index 200aee93a..11d18431d 100644 --- a/pkg/lint/rules/testdata/albatross/templates/_helpers.tpl +++ b/pkg/lint/rules/testdata/albatross/templates/_helpers.tpl @@ -2,7 +2,7 @@ {{/* Expand the name of the chart. */}} -{{define "name"}}{{default "nginx" .Values.nameOverride | trunc 24 }}{{end}} +{{define "name"}}{{default "nginx" .Values.nameOverride | trunc 24 | trimSuffix "-" }}{{end}} {{/* Create a default fully qualified app name. @@ -12,5 +12,5 @@ We truncate at 24 chars because some Kubernetes name fields are limited to this */}} {{define "fullname"}} {{- $name := default "nginx" .Values.nameOverride -}} -{{printf "%s-%s" .Release.Name $name | trunc 24 -}} +{{printf "%s-%s" .Release.Name $name | trunc 24 | trimSuffix "-" -}} {{end}}