[COMMON] Allow to generate fullname based on passed chart name 67/100567/4
authorKrzysztof Opasiak <k.opasiak@samsung.com>
Fri, 24 Jan 2020 23:00:07 +0000 (00:00 +0100)
committerKrzysztof Opasiak <k.opasiak@samsung.com>
Fri, 31 Jan 2020 23:10:01 +0000 (00:10 +0100)
By default common.fullname uses .Chart.Name or
.Values.nameOverride to generate a "full name" used in many
places.

In some cases it may be convenient to be able to generate this
full name for a specific, well known chart name.

Issue-ID: OOM-2249
Change-Id: I68034c1c5df81ae9533f5f4bc6fab58f2416623a
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
kubernetes/common/common/templates/_name.tpl

index 9b7e690..7719cdb 100644 (file)
   {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
 {{- end -}}
 
+{{/*
+  The same as common.full name but based on passed dictionary instead of trying to figure
+  out chart name on its own.
+*/}}
+{{- define "common.fullnameExplicit" -}}
+  {{- $dot := .dot }}
+  {{- $name := .chartName }}
+  {{- printf "%s-%s" (include "common.release" $dot) $name | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
+
 {{/*
   Create a default fully qualified application name.
   Truncated at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
 */}}
 {{- define "common.fullname" -}}
   {{- $name := default .Chart.Name .Values.nameOverride -}}
-  {{- printf "%s-%s" (include "common.release" .) $name | trunc 63 | trimSuffix "-" -}}
+  {{- include "common.fullnameExplicit" (dict "dot" . "chartName" $name) }}
 {{- end -}}
 
 {{/*