From fe6b70f42e785ea384a8c1b655cdb9185848135c Mon Sep 17 00:00:00 2001
From: groundhog2k <10630407+groundhog2k@users.noreply.github.com>
Date: Thu, 24 Dec 2020 11:19:33 +0100
Subject: [PATCH] Email config support and documentation (#161)

* Added email config support (env vars did not work because of escape)

* Incremented chart version

* Added parameter description

Co-authored-by: Aram Karapetyan <aram@fouraitch.com>
---
 charts/ghost/Chart.yaml                  |  2 +-
 charts/ghost/README.md                   |  9 ++++++++-
 charts/ghost/templates/deployment.yaml   | 24 ++++++++++++++++++++++++
 charts/ghost/templates/secureconfig.yaml |  3 +++
 charts/ghost/values.yaml                 | 10 ++++++++++
 5 files changed, 46 insertions(+), 2 deletions(-)

diff --git a/charts/ghost/Chart.yaml b/charts/ghost/Chart.yaml
index a663387a..31a647aa 100644
--- a/charts/ghost/Chart.yaml
+++ b/charts/ghost/Chart.yaml
@@ -7,7 +7,7 @@ type: application
 maintainers:
   - name: groundhog2k
 
-version: 0.2.6
+version: 0.2.7
 
 appVersion: "3.40.2"
 
diff --git a/charts/ghost/README.md b/charts/ghost/README.md
index 79ca05f3..10308987 100644
--- a/charts/ghost/README.md
+++ b/charts/ghost/README.md
@@ -1,6 +1,6 @@
 # Ghost
 
-![Version: 0.2.6](https://img.shields.io/badge/Version-0.2.6-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 3.40.2](https://img.shields.io/badge/AppVersion-3.40.1-informational?style=flat-square)
+![Version: 0.2.7](https://img.shields.io/badge/Version-0.2.7-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 3.40.2](https://img.shields.io/badge/AppVersion-3.40.1-informational?style=flat-square)
 
 A Helm chart for Ghost blog on Kubernetes
 
@@ -123,3 +123,10 @@ $ helm uninstall my-release
 | externalDatabase.password | string | `nil` | External database password |
 | settings.mode | string | `"production"` | Ghost mode (production or development) |
 | settings.url | string | `nil` | URL of Ghost blog |
+| settings.mail.from | string | `nil` | Mail from address |
+| settings.mail.transport | string | `SMTP` | Mail transport type (SMTP, Sendmail, Direct) |
+| settings.mail.host | string | `nil` | Mail host for transport |
+| settings.mail.port | int | `nil` | Mail port  for transport |
+| settings.mail.service | string | `nil` | Service for mail transport (Mailgun, Sendgrid, Gmail, SES) |
+| settings.mail.user | string | `nil` | Mail auth user |
+| settings.mail.passwort | string | `nil` | Mail auth password |
diff --git a/charts/ghost/templates/deployment.yaml b/charts/ghost/templates/deployment.yaml
index d4384d54..90224fb8 100644
--- a/charts/ghost/templates/deployment.yaml
+++ b/charts/ghost/templates/deployment.yaml
@@ -47,6 +47,30 @@ spec:
             - name: url
               value: {{ .Values.settings.url }}
             {{- end }}
+            {{- if .Values.settings.mail.from }}
+            - name: mail__from
+              value: {{ .Values.settings.mail.from | quote }}
+            {{- end }}
+            {{- if .Values.settings.mail.transport }}
+            - name: mail__transport
+              value: {{ .Values.settings.mail.transport | quote }}
+            {{- end }}
+            {{- if .Values.settings.mail.host }}
+            - name: mail__options__host
+              value: {{ .Values.settings.mail.host | quote }}
+            {{- end }}
+            {{- if .Values.settings.mail.port }}
+            - name: mail__options__port
+              value: {{ .Values.settings.mail.port | quote }}
+            {{- end }}
+            {{- if .Values.settings.mail.service }}
+            - name: mail__options__service
+              value: {{ .Values.settings.mail.service | quote }}
+            {{- end }}
+            {{- if .Values.settings.mail.user }}
+            - name: mail__options__auth__user
+              value: {{ .Values.settings.mail.user | quote }}
+            {{- end }}
           {{- with .Values.env }}
             {{- toYaml . | nindent 12 }}
           {{- end }}    
diff --git a/charts/ghost/templates/secureconfig.yaml b/charts/ghost/templates/secureconfig.yaml
index 3fcdd3fc..90426966 100644
--- a/charts/ghost/templates/secureconfig.yaml
+++ b/charts/ghost/templates/secureconfig.yaml
@@ -27,4 +27,7 @@ stringData:
   database__client: "sqlite3"
   {{- end }}
   {{- end }}
+{{- end }}
+{{- if .Values.settings.mail.password }}
+  mail__options__auth__pass: {{ .Values.settings.mail.password }}
 {{- end }}
\ No newline at end of file
diff --git a/charts/ghost/values.yaml b/charts/ghost/values.yaml
index 8baaf952..02ca11be 100644
--- a/charts/ghost/values.yaml
+++ b/charts/ghost/values.yaml
@@ -136,6 +136,16 @@ settings:
   ## Environment mode (development or production - default: production)
   mode: production
 
+  ## SMTP connection details
+  mail:
+    from:
+    transport: SMTP
+    host:
+    port:
+    service:
+    user:
+    password:
+
 ## Storage parameters
 storage:
   ##  Set persistentVolumenClaimName to reference an existing PVC
-- 
GitLab