2 # Copyright © 2017 Amdocs, Bell Canada
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
18 Expand the name of a chart.
19 The function takes from one to two arguments (inside a dictionary):
20 - .dot : environment (.)
21 - .suffix : add a suffix to the name
23 {{- define "common.name" -}}
24 {{- $dot := default . .dot -}}
25 {{- $suffix := .suffix -}}
26 {{- default $dot.Chart.Name $dot.Values.nameOverride | trunc 63 | trimSuffix "-" -}}{{ if $suffix }}{{ print "-" $suffix }}{{ end }}
30 The same as common.full name but based on passed dictionary instead of trying to figure
31 out chart name on its own.
33 {{- define "common.fullnameExplicit" -}}
35 {{- $name := .chartName }}
36 {{- $suffix := default "" .suffix -}}
37 {{- printf "%s-%s-%s" (include "common.release" $dot) $name $suffix | trunc 63 | trimSuffix "-" | trimSuffix "-" -}}
41 Create a default fully qualified application name.
42 Truncated at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
44 include "common.fullname" .
45 include "common.fullname" (dict "suffix" "mySuffix" "dot" .)
46 The function takes from one to two arguments:
47 - .dot : environment (.)
48 - .suffix : add a suffix to the fullname
50 {{- define "common.fullname" -}}
51 {{- $dot := default . .dot -}}
52 {{- $suffix := default "" .suffix -}}
53 {{- $name := default $dot.Chart.Name $dot.Values.nameOverride -}}
54 {{/* when linted, the name must be lower cased. When used from a component,
55 name should be overriden in order to avoid collision so no need to do it */}}
56 {{- if eq (printf "%s/templates" $name) $dot.Template.BasePath -}}
57 {{- $name = lower $name -}}
59 {{- include "common.fullnameExplicit" (dict "dot" $dot "chartName" $name "suffix" $suffix) }}
63 Retrieve the "original" release from the component release:
64 if ONAP is deploy with "helm deploy --name toto", then cassandra components
65 will have "toto-cassandra" as release name.
66 this function would answer back "toto".
68 {{- define "common.release" -}}
69 {{- first (regexSplit "-" .Release.Name -1) }}
72 {{- define "common.chart" -}}
73 {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}