Skip to content

Commit

Permalink
feat(kratos): add possibility to configure email template overrides (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianvoss committed Jan 25, 2021
1 parent d2be644 commit 087ec6e
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
22 changes: 22 additions & 0 deletions helm/charts/kratos/templates/configmap-templates.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
16 changes: 16 additions & 0 deletions helm/charts/kratos/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand All @@ -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
Expand Down
30 changes: 30 additions & 0 deletions helm/charts/kratos/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
#
# <a href="{{ .RecoveryURL }}">{{ .RecoveryURL }}</a>
# 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:
#
# <a href="{{ .RecoveryURL }}">{{ .RecoveryURL }}</a>
# invalid:
# subject:
# body:

config:
courier:
smtp: {}
#template_override_path: /conf/courier-templates

serve:
public:
Expand Down

0 comments on commit 087ec6e

Please sign in to comment.