[COMMON] Create templates for services and PV
[oom.git] / kubernetes / common / common / templates / _name.tpl
index f84ca21..943078f 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" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
+  {{- include "common.fullnameExplicit" (dict "dot" . "chartName" $name) }}
 {{- end -}}
 
 {{/*
@@ -37,5 +47,9 @@
   this function would answer back "toto".
 */}}
 {{- define "common.release" -}}
-  {{- regexReplaceAll "-[a-zA-Z0-9]*$" .Release.Name ""  }}
+  {{- first (regexSplit "-" .Release.Name -1)  }}
+{{- end -}}
+
+{{- define "common.chart" -}}
+{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
 {{- end -}}