From fb8b36616116c37be02630e179fd48c7c3ac05b7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=B6ran=20P=C3=B6hner?=
 <10630407+groundhog2k@users.noreply.github.com>
Date: Tue, 13 Jun 2023 20:41:34 +0200
Subject: [PATCH] Groundhog2k/issue1250 (#1252)

---
 charts/remark42/Chart.yaml                     |  2 +-
 charts/remark42/README.md                      |  8 +++++++-
 charts/remark42/RELEASENOTES.md                |  1 +
 charts/remark42/templates/_helpers.tpl         | 15 ++++++++++++++-
 charts/remark42/templates/extraressources.yaml |  4 ++++
 charts/remark42/values.yaml                    | 18 ++++++++++++++++++
 6 files changed, 45 insertions(+), 3 deletions(-)
 create mode 100644 charts/remark42/templates/extraressources.yaml

diff --git a/charts/remark42/Chart.yaml b/charts/remark42/Chart.yaml
index 1dca2e1b..2e0d9064 100644
--- a/charts/remark42/Chart.yaml
+++ b/charts/remark42/Chart.yaml
@@ -7,7 +7,7 @@ type: application
 maintainers:
   - name: groundhog2k
 
-version: "0.5.9"
+version: "0.5.10"
 
 appVersion: "v1.11.3"
 
diff --git a/charts/remark42/README.md b/charts/remark42/README.md
index bbafc75c..7365cca3 100644
--- a/charts/remark42/README.md
+++ b/charts/remark42/README.md
@@ -1,6 +1,6 @@
 # Remark42
 
-![Version: 0.5.9](https://img.shields.io/badge/Version-0.5.9-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v1.11.3](https://img.shields.io/badge/AppVersion-v1.11.3-informational?style=flat-square)
+![Version: 0.5.10](https://img.shields.io/badge/Version-0.5.10-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v1.11.3](https://img.shields.io/badge/AppVersion-v1.11.3-informational?style=flat-square)
 
 A Helm chart for Remark42 on Kubernetes
 
@@ -245,3 +245,9 @@ helm uninstall my-release
 | storage.requestedSize | string | `nil` | Size for new PVC, when no existing PVC is used |
 | storage.className | string | `nil` | Storage class name |
 | storage.keepPvc | bool | `false` | Keep a created Persistent volume claim when uninstalling the helm chart |
+
+## Extra resources
+
+| Key | Type | Default | Description |
+|-----|------|---------|-------------|
+| extraResources | list | `nil` | List of extra resource deployments |
diff --git a/charts/remark42/RELEASENOTES.md b/charts/remark42/RELEASENOTES.md
index 7a41dfd4..6165ce97 100644
--- a/charts/remark42/RELEASENOTES.md
+++ b/charts/remark42/RELEASENOTES.md
@@ -24,4 +24,5 @@
 | 0.5.7 | v1.11.3 | Updated chart dependencies (redis 0.6.10) |
 | 0.5.8 | v1.11.3 | Updated chart dependencies (redis 0.6.11) |
 | 0.5.9 | v1.11.3 | Added support for init container command and arguments (thx @IxDay) |
+| 0.5.10 | v1.11.3 | Added support for extraResources (thx @IxDay) |
 | | | |
diff --git a/charts/remark42/templates/_helpers.tpl b/charts/remark42/templates/_helpers.tpl
index 14dd6ef5..3f16ca7a 100644
--- a/charts/remark42/templates/_helpers.tpl
+++ b/charts/remark42/templates/_helpers.tpl
@@ -260,4 +260,17 @@ Commento settings via environment variables
   value: "{{ .Values.externalCache.host }}:{{ .Values.externalCache.port }}"
 {{- end }}
 {{- end }}
-{{- end }}
\ No newline at end of file
+{{- end }}
+
+{{/*
+Renders a value that contains template.
+Usage:
+{{ include "remark42.render" ( dict "value" .Values.path.to.the.Value "context" $) }}
+*/}}
+{{- define "remark42.render" -}}
+  {{- if typeIs "string" .value }}
+    {{- tpl .value .context }}
+  {{- else }}
+    {{- tpl (.value | toYaml) .context }}
+  {{- end }}
+{{- end -}}
diff --git a/charts/remark42/templates/extraressources.yaml b/charts/remark42/templates/extraressources.yaml
new file mode 100644
index 00000000..4bd6f75a
--- /dev/null
+++ b/charts/remark42/templates/extraressources.yaml
@@ -0,0 +1,4 @@
+{{- range .Values.extraResources }}
+---
+{{- include "remark42.render" (dict "value" . "context" $) }}
+{{- end }}
diff --git a/charts/remark42/values.yaml b/charts/remark42/values.yaml
index b1ab58de..1f6f753b 100644
--- a/charts/remark42/values.yaml
+++ b/charts/remark42/values.yaml
@@ -406,3 +406,21 @@ redis:
 
     ## the storage class name
     className:
+
+extraResources: []
+  # - |
+  #   apiVersion: projectcontour.io/v1
+  #   kind: HTTPProxy
+  #   metadata:
+  #     name: {{ include "remark42.fullname" . }}
+  #     namespace: {{ .Values.namespace | default .Release.Namespace }}
+  #     labels:
+  #       {{- include "remark42.labels" . | nindent 4 }}
+  #   spec:
+  #     ingressClassName: contour
+  #     virtualhost:
+  #       fqdn: {{.Values.settings.url | trimPrefix "http://"}}
+  #     routes:
+  #     - services:
+  #       - name: {{ include "remark42.fullname" . }}
+  #         port: {{ .Values.service.port }}
-- 
GitLab