From 087ec6edabcf7c6c864e9c12b26309ce23d6ce17 Mon Sep 17 00:00:00 2001 From: Sebastian Voss Date: Mon, 25 Jan 2021 15:45:02 +0100 Subject: [PATCH] feat(kratos): add possibility to configure email template overrides (#218) --- .../kratos/templates/configmap-templates.yaml | 22 ++++++++++++++ helm/charts/kratos/templates/deployment.yaml | 16 ++++++++++ helm/charts/kratos/values.yaml | 30 +++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 helm/charts/kratos/templates/configmap-templates.yaml diff --git a/helm/charts/kratos/templates/configmap-templates.yaml b/helm/charts/kratos/templates/configmap-templates.yaml new file mode 100644 index 000000000..b67a04c04 --- /dev/null +++ b/helm/charts/kratos/templates/configmap-templates.yaml @@ -0,0 +1,22 @@ +{{- $root := . -}} +{{- range $method, $methodEntry := .Values.kratos.emailTemplates }} +{{- range $result, $resultEntry := $methodEntry }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "kratos.fullname" $root }}-template-{{ $method }}-{{ $result }} + namespace: {{ $root.Release.Namespace }} + labels: +{{ include "kratos.labels" $root | indent 4 }} +data: + {{- if $resultEntry.subject }} + "email.subject.gotmpl": | + {{ $resultEntry.subject | quote }} + {{- end }} + {{- if $resultEntry.body }} + "email.body.gotmpl": |- +{{ $resultEntry.body | indent 4 }} + {{- end }} +{{- end }} +{{- end }} diff --git a/helm/charts/kratos/templates/deployment.yaml b/helm/charts/kratos/templates/deployment.yaml index b3374e1c9..fe0c43309 100644 --- a/helm/charts/kratos/templates/deployment.yaml +++ b/helm/charts/kratos/templates/deployment.yaml @@ -111,6 +111,14 @@ spec: name: {{ include "kratos.name" . }}-config-volume configMap: name: {{ include "kratos.fullname" . }}-config + {{- $root := . -}} + {{- range $method, $methodEntry := .Values.kratos.emailTemplates }} + {{- range $result, $resultEntry := $methodEntry }} + - name: {{ include "kratos.name" $root }}-template-{{ $method }}-{{ $result }}-volume + configMap: + name: {{ include "kratos.fullname" $root }}-template-{{ $method }}-{{ $result }} + {{- end }} + {{- end }} containers: - name: {{ .Chart.Name }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" @@ -130,6 +138,14 @@ spec: name: {{ include "kratos.name" . }}-config-volume mountPath: /etc/config readOnly: true + {{- $root := . -}} + {{- range $method, $methodEntry := .Values.kratos.emailTemplates }} + {{- range $result, $resultEntry := $methodEntry }} + - name: {{ include "kratos.name" $root }}-template-{{ $method }}-{{ $result }}-volume + mountPath: /conf/courier-templates/{{ $method }}/{{ $result }} + readOnly: true + {{- end }} + {{- end }} env: - name: DSN diff --git a/helm/charts/kratos/values.yaml b/helm/charts/kratos/values.yaml index f5b956bd9..6b1257356 100644 --- a/helm/charts/kratos/values.yaml +++ b/helm/charts/kratos/values.yaml @@ -85,9 +85,39 @@ kratos: # // ... # } +# You can customize the emails kratos is sending (also uncomment config.courier.template_override_path below) +# Note: If you are setting config.courier.template_override_path you need to supply overrides for all templates. +# It is currently not possible to overrides only selected methods. +# +# emailTemplates: +# recovery: +# valid: +# subject: Recover access to your account +# body: |- +# Hi, please recover access to your account by clicking the following link: +# +# {{ .RecoveryURL }} +# invalid: +# subject: Account access attempted +# body: |- +# Hi, you (or someone else) entered this email address when trying to recover access to an account. +# +# However, this email address is not on our database of registered users and therefore the attempt has failed. If this was you, check if you signed up using a different address. If this was not you, please ignore this email. +# verification: +# valid: +# subject: Please verify your email address +# body: |- +# Hi, please verify your account by clicking the following link: +# +# {{ .RecoveryURL }} +# invalid: +# subject: +# body: + config: courier: smtp: {} + #template_override_path: /conf/courier-templates serve: public: