Initial Version of Helm Chart for OpenDaylight
[integration/packaging.git] / helm / opendaylight / templates / _helpers.tpl
1 {{/*
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2021 The Linux Foundation and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
11 */}}
12 {{/*
13 Expand the name of the chart.
14 */}}
15 {{- define "opendaylight.name" -}}
16 {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
17 {{- end }}
18
19 {{/*
20 Create a default fully qualified app name.
21 We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
22 If release name contains chart name it will be used as a full name.
23 */}}
24 {{- define "opendaylight.fullname" -}}
25 {{- if .Values.fullnameOverride }}
26 {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
27 {{- else }}
28 {{- $name := default .Chart.Name .Values.nameOverride }}
29 {{- if contains $name .Release.Name }}
30 {{- .Release.Name | trunc 63 | trimSuffix "-" }}
31 {{- else }}
32 {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
33 {{- end }}
34 {{- end }}
35 {{- end }}
36
37 {{/*
38 Create chart name and version as used by the chart label.
39 */}}
40 {{- define "opendaylight.chart" -}}
41 {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
42 {{- end }}
43
44 {{/*
45 Common labels
46 */}}
47 {{- define "opendaylight.labels" -}}
48 helm.sh/chart: {{ include "opendaylight.chart" . }}
49 {{ include "opendaylight.selectorLabels" . }}
50 {{- if .Chart.AppVersion }}
51 app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
52 {{- end }}
53 app.kubernetes.io/managed-by: {{ .Release.Service }}
54 {{- end }}
55
56 {{/*
57 Selector labels
58 */}}
59 {{- define "opendaylight.selectorLabels" -}}
60 app.kubernetes.io/name: {{ include "opendaylight.name" . }}
61 app.kubernetes.io/instance: {{ .Release.Name }}
62 {{- end }}
63
64 {{/*
65 Create the name of the service account to use
66 */}}
67 {{- define "opendaylight.serviceAccountName" -}}
68 {{- if .Values.serviceAccount.create }}
69 {{- default (include "opendaylight.fullname" .) .Values.serviceAccount.name }}
70 {{- else }}
71 {{- default "default" .Values.serviceAccount.name }}
72 {{- end }}
73 {{- end }}