d179779608810a1614cdd6d3ef24ef48b58c314a
[ric-plt/ric-dep.git] / helm / infrastructure / subcharts / kong / charts / postgresql / templates / _helpers.tpl
1 {{/* vim: set filetype=mustache: */}}
2 {{/*
3 Expand the name of the chart.
4 */}}
5 {{- define "postgresql.name" -}}
6 {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7 {{- end -}}
8
9 {{/*
10 Create a default fully qualified app name.
11 We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12 */}}
13 {{- define "postgresql.fullname" -}}
14 {{- if .Values.fullnameOverride -}}
15 {{- printf .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
16 {{- else -}}
17 {{- $name := default .Chart.Name .Values.nameOverride -}}
18 {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
19 {{- end -}}
20 {{- end -}}
21
22 {{/*
23 Create a default fully qualified app name.
24 We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
25 */}}
26 {{- define "postgresql.master.fullname" -}}
27 {{- $name := default .Chart.Name .Values.nameOverride -}}
28 {{- $fullname := default (printf "%s-%s" .Release.Name $name) .Values.fullnameOverride -}}
29 {{- if .Values.replication.enabled -}}
30 {{- printf "%s-%s" $fullname "master" | trunc 63 | trimSuffix "-" -}}
31 {{- else -}}
32 {{- printf "%s" $fullname | trunc 63 | trimSuffix "-" -}}
33 {{- end -}}
34 {{- end -}}
35
36 {{/*
37 Return the appropriate apiVersion for networkpolicy.
38 */}}
39 {{- define "postgresql.networkPolicy.apiVersion" -}}
40 {{- if semverCompare ">=1.4-0, <1.7-0" .Capabilities.KubeVersion.GitVersion -}}
41 "extensions/v1beta1"
42 {{- else if semverCompare "^1.7-0" .Capabilities.KubeVersion.GitVersion -}}
43 "networking.k8s.io/v1"
44 {{- end -}}
45 {{- end -}}
46
47 {{/*
48 Create chart name and version as used by the chart label.
49 */}}
50 {{- define "postgresql.chart" -}}
51 {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
52 {{- end -}}
53
54 {{/*
55 Return the proper PostgreSQL image name
56 */}}
57 {{- define "postgresql.image" -}}
58 {{- $registryName := .Values.image.registry -}}
59 {{- $repositoryName := .Values.image.repository -}}
60 {{- $tag := .Values.image.tag | toString -}}
61 {{/*
62 Helm 2.11 supports the assignment of a value to a variable defined in a different scope,
63 but Helm 2.9 and 2.10 doesn't support it, so we need to implement this if-else logic.
64 Also, we can't use a single if because lazy evaluation is not an option
65 */}}
66 {{- if .Values.global }}
67     {{- if .Values.global.imageRegistry }}
68         {{- printf "%s/%s:%s" .Values.global.imageRegistry $repositoryName $tag -}}
69     {{- else -}}
70         {{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
71     {{- end -}}
72 {{- else -}}
73     {{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
74 {{- end -}}
75 {{- end -}}
76
77 {{/*
78 Return the proper image name to change the volume permissions
79 */}}
80 {{- define "postgresql.volumePermissions.image" -}}
81 {{- $registryName := .Values.volumePermissions.image.registry -}}
82 {{- $repositoryName := .Values.volumePermissions.image.repository -}}
83 {{- $tag := .Values.volumePermissions.image.tag | toString -}}
84 {{/*
85 Helm 2.11 supports the assignment of a value to a variable defined in a different scope,
86 but Helm 2.9 and 2.10 doesn't support it, so we need to implement this if-else logic.
87 Also, we can't use a single if because lazy evaluation is not an option
88 */}}
89 {{- if .Values.global }}
90     {{- if .Values.global.imageRegistry }}
91         {{- printf "%s/%s:%s" .Values.global.imageRegistry $repositoryName $tag -}}
92     {{- else -}}
93         {{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
94     {{- end -}}
95 {{- else -}}
96     {{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
97 {{- end -}}
98 {{- end -}}
99
100
101 {{/*
102 Return the proper PostgreSQL metrics image name
103 */}}
104 {{- define "metrics.image" -}}
105 {{- $registryName :=  default "docker.io" .Values.metrics.image.registry -}}
106 {{- $tag := default "latest" .Values.metrics.image.tag | toString -}}
107 {{- printf "%s/%s:%s" $registryName .Values.metrics.image.repository $tag -}}
108 {{- end -}}
109
110 {{/*
111 Get the password secret.
112 */}}
113 {{- define "postgresql.secretName" -}}
114 {{- if .Values.existingSecret -}}
115 {{- printf "%s" .Values.existingSecret -}}
116 {{- else -}}
117 {{- printf "%s" (include "postgresql.fullname" .) -}}
118 {{- end -}}
119 {{- end -}}
120
121 {{/*
122 Get the configuration ConfigMap name.
123 */}}
124 {{- define "postgresql.configurationCM" -}}
125 {{- if .Values.configurationConfigMap -}}
126 {{- printf "%s" .Values.configurationConfigMap -}}
127 {{- else -}}
128 {{- printf "%s-configuration" (include "postgresql.fullname" .) -}}
129 {{- end -}}
130 {{- end -}}
131
132 {{/*
133 Get the extended configuration ConfigMap name.
134 */}}
135 {{- define "postgresql.extendedConfigurationCM" -}}
136 {{- if .Values.extendedConfConfigMap -}}
137 {{- printf "%s" .Values.extendedConfConfigMap -}}
138 {{- else -}}
139 {{- printf "%s-extended-configuration" (include "postgresql.fullname" .) -}}
140 {{- end -}}
141 {{- end -}}
142
143 {{/*
144 Get the initialization scripts ConfigMap name.
145 */}}
146 {{- define "postgresql.initdbScriptsCM" -}}
147 {{- if .Values.initdbScriptsConfigMap -}}
148 {{- printf "%s" .Values.initdbScriptsConfigMap -}}
149 {{- else -}}
150 {{- printf "%s-init-scripts" (include "postgresql.fullname" .) -}}
151 {{- end -}}
152 {{- end -}}