From e85e1718defe73ecde0962ae2491c72a8f9aef40 Mon Sep 17 00:00:00 2001
From: luhahn <luhahn@noreply.gitea.io>
Date: Thu, 3 Sep 2020 21:27:11 +0000
Subject: [PATCH] Fix memcached conditional and external database check in init
 container (#18)

Bump chart version

Update README.md with example for DB

Fix external host check for Databases

Fix condition for memcached in Chart.yaml

Co-authored-by: Lucas Hahn <lucas.hahn@novum-rgi.de>
Reviewed-on: https://gitea.com/gitea/helm-chart/pulls/18
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
Reviewed-by: Andrew Thornton <art27@cantab.net>
---
 Chart.yaml             |  4 ++--
 README.md              | 22 ++++++++++++++++++++--
 templates/_helpers.tpl |  4 ++--
 3 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/Chart.yaml b/Chart.yaml
index 5bcddf4..494ea96 100644
--- a/Chart.yaml
+++ b/Chart.yaml
@@ -2,7 +2,7 @@ apiVersion: v2
 name: gitea
 description: Gitea Helm chart for Kubernetes
 type: application
-version: 1.4.2
+version: 1.4.3
 appVersion: 1.12.3
 icon: https://docs.gitea.io/images/gitea.png
 
@@ -30,7 +30,7 @@ dependencies:
 - name: memcached
   repository: https://charts.bitnami.com/bitnami
   version: 4.2.20
-  condition: gitea.cache.enabled
+  condition: gitea.cache.builtIn.enabled
 - name: mysql
   repository: https://charts.bitnami.com/bitnami
   version: 6.14.8
diff --git a/README.md b/README.md
index e427daa..e9a0079 100644
--- a/README.md
+++ b/README.md
@@ -2,8 +2,6 @@
 
 [Gitea](https://gitea.io/en-us/) is a community managed lightweight code hosting solution written in Go. It is published under the MIT license.
 
-Readme will be updated with examples in the next few days
-
 ## Introduction
 
 This helm chart has taken some inspiration from https://github.com/jfelten/gitea-helm-chart
@@ -49,6 +47,26 @@ Gitea offers lots of configuration. This is fully described in the [Gitea Cheat
       repository.pull-request:
         WORK_IN_PROGRESS_PREFIXES: "WIP:,[WIP]:"
 ```
+### External Database
+
+An external Database can be used instead of builtIn postgresql or mysql.
+
+```yaml
+  gitea:
+    database:
+      builtIn:
+        postgresql:
+          enabled: false
+
+    config:
+      database:
+        DB_TYPE: mysql
+        HOST: 127.0.0.1:3306
+        NAME: gitea
+        USER: root
+        PASSWD: gitea
+      SCHEMA: gitea
+```
 
 ### Ports and external url
 
diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl
index 6ccd2e7..86d72b1 100644
--- a/templates/_helpers.tpl
+++ b/templates/_helpers.tpl
@@ -61,7 +61,8 @@ app.kubernetes.io/instance: {{ .Release.Name }}
 {{- else if .Values.gitea.database.builtIn.mysql.enabled -}}
 {{- printf "%s-mysql" .Release.Name -}}
 {{- else -}}
-{{ .Values.gitea.database.external.host }}
+{{- $parts := split ":" .Values.gitea.config.database.HOST -}}
+{{- printf "%s %s" $parts._0 $parts._1 -}}
 {{- end -}}
 {{- end -}}
 
@@ -71,7 +72,6 @@ app.kubernetes.io/instance: {{ .Release.Name }}
 {{- else if .Values.gitea.database.builtIn.mysql.enabled -}}
 {{ .Values.mysql.service.port }}
 {{- else -}}
-{{ .Values.gitea.database.external.port }}
 {{- end -}}
 {{- end -}}