Skip to content

Commit 90a196b

Browse files
committed
feat(drupal): Proper secret handling
1 parent aa22980 commit 90a196b

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

charts/drupal/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: drupal
22
apiVersion: v2
33
type: application
4-
version: 2.0.0-beta6
4+
version: 2.0.0-beta7
55
appVersion: 6.1.4
66
description: Helm Chart for deploying an enterprise-grade Drupal environment.
77
keywords:

charts/drupal/templates/_helpers.tpl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Create common environment variables for Drupal
7878
- name: EXTERNAL_PASSWORD
7979
valueFrom:
8080
secretKeyRef:
81-
name: {{ template "drupal.fullname" . }}
81+
name: {{ default (include "drupal.fullname" .) .Values.drupal.existingSecret }}
8282
key: databasePassword
8383
{{- else if and .Values.mysql.enabled }}
8484
- name: MYSQL_PASSWORD
@@ -101,10 +101,15 @@ Create common environment variables for Drupal
101101
key: default-password
102102
{{- end }}
103103
{{- if not .Values.drupal.usePasswordFiles }}
104+
- name: DRUPAL_ADMIN
105+
valueFrom:
106+
secretKeyRef:
107+
name: {{ default (include "drupal.fullname" .) .Values.drupal.existingSecret }}
108+
key: username
104109
- name: DRUPAL_ADMIN_PASSWORD
105110
valueFrom:
106111
secretKeyRef:
107-
name: {{ include "drupal.fullname" . }}
112+
name: {{ default (include "drupal.fullname" .) .Values.drupal.existingSecret }}
108113
key: password
109114
{{- end }}
110115
{{- end -}}
Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
1-
{{- if not .Values.drupal.usePasswordFiles }}
2-
{{- $name := include "drupal.fullname" . -}}
3-
{{- $existing := lookup "v1" "Secret" .Release.Namespace $name -}}
1+
{{- if and (not .Values.drupal.usePasswordFiles) (not .Values.drupal.existingSecret) }}
42
apiVersion: v1
53
kind: Secret
64
metadata:
7-
name: {{ $name }}
5+
name: {{ include "drupal.fullname" . }}
86
labels:
97
app.kubernetes.io/name: {{ include "drupal.name" . }}
108
helm.sh/chart: {{ include "drupal.chart" . }}
119
app.kubernetes.io/instance: {{ .Release.Name }}
1210
app.kubernetes.io/managed-by: {{ .Release.Service }}
1311
type: Opaque
1412
data:
15-
username: {{ if and $existing (hasKey $existing.data "username") }}{{ index $existing.data "username" | quote }}{{ else if .Values.drupal.username }}{{ .Values.drupal.username | b64enc | quote }}{{ else }}{{ "admin" | b64enc | quote }}{{ end }}
16-
password: {{ if and $existing (hasKey $existing.data "password") }}{{ index $existing.data "password" | quote }}{{ else if .Values.drupal.password }}{{ .Values.drupal.password | b64enc | quote }}{{ else }}{{ randAlphaNum 10 | b64enc | quote }}{{ end }}
13+
username: {{ default "admin" .Values.drupal.username | b64enc | quote }}
14+
password: {{ default (randAlphaNum 10) .Values.drupal.password | b64enc | quote }}
1715
{{- if .Values.external.enabled }}
18-
databasePassword: {{ if and $existing (hasKey $existing.data "databasePassword") }}{{ index $existing.data "databasePassword" | quote }}{{ else }}{{ .Values.external.password | b64enc | quote }}{{ end }}
16+
databasePassword: {{ .Values.external.password | b64enc | quote }}
1917
{{- end }}
2018
{{- end }}

charts/drupal/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ drupal:
6262
6363
## User of the application
6464
##
65+
existingSecret: ""
6566
username: admin
6667

6768
## Application password

0 commit comments

Comments
 (0)