1 {{/* vim: set filetype=mustache: */}}
3 Expand the name of the chart.
5 {{- define "apache.name" -}}
6 {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
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).
13 {{- define "apache.fullname" -}}
14 {{- if .Values.fullnameOverride -}}
15 {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
17 {{- $name := default .Chart.Name .Values.nameOverride -}}
18 {{- if contains $name .Release.Name -}}
19 {{- .Release.Name | trunc 63 | trimSuffix "-" -}}
21 {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
29 {{- define "apache.labels" -}}
30 app.kubernetes.io/name: {{ include "apache.name" . }}
31 helm.sh/chart: {{ include "apache.chart" . }}
32 app.kubernetes.io/instance: {{ .Release.Name }}
33 app.kubernetes.io/managed-by: {{ .Release.Service }}
37 Labels to use on deploy.spec.selector.matchLabels and svc.spec.selector
39 {{- define "apache.matchLabels" -}}
40 app.kubernetes.io/name: {{ include "apache.name" . }}
41 app.kubernetes.io/instance: {{ .Release.Name }}
45 Return the proper Apache image name
47 {{- define "apache.image" -}}
48 {{- $registryName := .Values.image.registry -}}
49 {{- $repositoryName := .Values.image.repository -}}
50 {{- $tag := .Values.image.tag | toString -}}
52 Helm 2.11 supports the assignment of a value to a variable defined in a different scope,
53 but Helm 2.9 and 2.10 doesn't support it, so we need to implement this if-else logic.
54 Also, we can't use a single if because lazy evaluation is not an option
56 {{- if .Values.global }}
57 {{- if .Values.global.imageRegistry }}
58 {{- printf "%s/%s:%s" .Values.global.imageRegistry $repositoryName $tag -}}
60 {{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
63 {{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
68 Return the proper Apache Docker Image Registry Secret Names
70 {{- define "apache.imagePullSecrets" -}}
72 Helm 2.11 supports the assignment of a value to a variable defined in a different scope,
73 but Helm 2.9 and 2.10 doesn't support it, so we need to implement this if-else logic.
74 Also, we can't use a single if because lazy evaluation is not an option
76 {{- if .Values.global }}
77 {{- if .Values.global.imagePullSecrets }}
79 {{- range .Values.global.imagePullSecrets }}
82 {{- else if or .Values.image.pullSecrets .Values.metrics.image.pullSecrets }}
84 {{- range .Values.image.pullSecrets }}
87 {{- range .Values.metrics.image.pullSecrets }}
91 {{- else if or .Values.image.pullSecrets .Values.metrics.image.pullSecrets }}
93 {{- range .Values.image.pullSecrets }}
96 {{- range .Values.metrics.image.pullSecrets }}
103 Return the proper image name (for the metrics image)
105 {{- define "apache.metrics.image" -}}
106 {{- $registryName := .Values.metrics.image.registry -}}
107 {{- $repositoryName := .Values.metrics.image.repository -}}
108 {{- $tag := .Values.metrics.image.tag | toString -}}
110 Helm 2.11 supports the assignment of a value to a variable defined in a different scope,
111 but Helm 2.9 and 2.10 doesn't support it, so we need to implement this if-else logic.
112 Also, we can't use a single if because lazy evaluation is not an option
114 {{- if .Values.global }}
115 {{- if .Values.global.imageRegistry }}
116 {{- printf "%s/%s:%s" .Values.global.imageRegistry $repositoryName $tag -}}
118 {{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
121 {{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
126 Return true if mouting a static web page
128 {{- define "apache.useHtdocs" -}}
129 {{ default "" (or .Values.cloneHtdocsFromGit.enabled .Values.htdocsConfigMap .Values.htdocsPVC) }}
133 Return associated volume
135 {{- define "apache.htdocsVolume" -}}
136 {{- if .Values.cloneHtdocsFromGit.enabled }}
138 {{- else if .Values.htdocsConfigMap }}
140 name: {{ .Values.htdocsConfigMap }}
141 {{- else if .Values.htdocsPVC }}
142 persistentVolumeClaim:
143 claimName: {{ .Values.htdocsPVC }}
150 {{- define "apache.validateValues" -}}
151 {{- $messages := list -}}
152 {{- $messages := append $messages (include "apache.validateValues.htdocs" .) -}}
153 {{- $messages := append $messages (include "apache.validateValues.htdocsGit" .) -}}
154 {{- $messages := without $messages "" -}}
155 {{- $message := join "\n" $messages -}}
157 {{- printf "\nVALUES VALIDATION:\n%s" $message | fail -}}
162 Create chart name and version as used by the chart label.
164 {{- define "apache.chart" -}}
165 {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
169 Validate data (htdocs)
171 {{- define "apache.validateValues.htdocs" -}}
172 {{- if or (and .Values.cloneHtdocsFromGit.enabled (or .Values.htdocsPVC .htdocsConfigMap )) (and .Values.htdocsPVC (or .Values.htdocsConfigMap .Values.cloneHtdocsFromGit.enabled )) (and .Values.htdocsConfigMap (or .Values.htdocsPVC .Values.cloneHtdocsFromGit.enabled )) }}
174 You have selected more than one way of deploying htdocs. Please select only one of htdocsConfigMap cloneHtdocsFromGit or htdocsVolume
179 Validate data (htdocs git)
181 {{- define "apache.validateValues.htdocsGit" -}}
182 {{- if .Values.cloneHtdocsFromGit.enabled }}
183 {{- if not .Values.cloneHtdocsFromGit.repository }}
184 apache: htdocs-git-repository
185 You did not specify a git repository to clone. Please set cloneHtdocsFromGit.repository
187 {{- if not .Values.cloneHtdocsFromGit.branch }}
188 apache: htdocs-git-branch
189 You did not specify a branch to checkout in the git repository. Please set cloneHtdocsFromGit.branch
195 Validate values of Apache - Incorrect extra volume settings
197 {{- define "apache.validateValues.extraVolumes" -}}
198 {{- if and (.Values.extraVolumes) (not .Values.extraVolumeMounts) -}}
199 apache: missing-extra-volume-mounts
200 You specified extra volumes but not mount points for them. Please set
201 the extraVolumeMounts value
206 Return the proper git image name
208 {{- define "git.image" -}}
209 {{- $registryName := .Values.git.registry -}}
210 {{- $repositoryName := .Values.git.repository -}}
211 {{- $tag := .Values.git.tag | toString -}}
213 Helm 2.11 supports the assignment of a value to a variable defined in a different scope,
214 but Helm 2.9 and 2.10 doesn't support it, so we need to implement this if-else logic.
215 Also, we can't use a single if because lazy evaluation is not an option
217 {{- if .Values.global }}
218 {{- if .Values.global.imageRegistry }}
219 {{- printf "%s/%s:%s" .Values.global.imageRegistry $repositoryName $tag -}}
221 {{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
224 {{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
229 Get the vhosts config map name.
231 {{- define "apache.vhostsConfigMap" -}}
232 {{- if .Values.vhostsConfigMap -}}
233 {{- printf "%s" (tpl .Values.vhostsConfigMap $) -}}
235 {{- printf "%s-vhosts" (include "apache.fullname" . ) -}}
240 Get the httpd.conf config map name.
242 {{- define "apache.httpdConfConfigMap" -}}
243 {{- if .Values.httpdConfConfigMap -}}
244 {{- printf "%s" (tpl .Values.httpdConfConfigMap $) -}}
246 {{- printf "%s-httpd-conf" (include "apache.fullname" . ) -}}
251 Renders a value that contains template.
253 {{ include "apache.tplValue" ( dict "value" .Values.path.to.the.Value "context" $) }}
255 {{- define "apache.tplValue" -}}
256 {{- if typeIs "string" .value }}
257 {{- tpl .value .context }}
259 {{- tpl (.value | toYaml) .context }}