From 8043039486ad8a7462a2880960eadaee46e55004 Mon Sep 17 00:00:00 2001
From: Maxime Vidori <maxime.vidori@gmail.com>
Date: Tue, 13 Jun 2023 20:31:48 +0200
Subject: [PATCH] Remark42: init container command improvement (#1249)

* Remark42: init container command improvement

This patch makes the command from the init container configurable.
It does not modify the previous behavior since it has been copy pasted
in the values.yaml file.
You can change initCommand and initArgs to change the default behavior.

Fixes #1248

* Updated chart version and documentation

---------

Co-authored-by: Goeran Poehner <goeran.poehner@gmail.com>
---
 charts/remark42/Chart.yaml                | 2 +-
 charts/remark42/README.md                 | 4 +++-
 charts/remark42/RELEASENOTES.md           | 1 +
 charts/remark42/templates/deployment.yaml | 4 ++--
 charts/remark42/values.yaml               | 9 +++++++++
 5 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/charts/remark42/Chart.yaml b/charts/remark42/Chart.yaml
index 449a8bea..1dca2e1b 100644
--- a/charts/remark42/Chart.yaml
+++ b/charts/remark42/Chart.yaml
@@ -7,7 +7,7 @@ type: application
 maintainers:
   - name: groundhog2k
 
-version: "0.5.8"
+version: "0.5.9"
 
 appVersion: "v1.11.3"
 
diff --git a/charts/remark42/README.md b/charts/remark42/README.md
index 6da0ab45..bbafc75c 100644
--- a/charts/remark42/README.md
+++ b/charts/remark42/README.md
@@ -1,6 +1,6 @@
 # Remark42
 
-![Version: 0.5.8](https://img.shields.io/badge/Version-0.5.8-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.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)
 
 A Helm chart for Remark42 on Kubernetes
 
@@ -62,6 +62,8 @@ helm uninstall my-release
 | image.registry | string | `"docker.io"` | Image registry |
 | image.repository | string | `"umputun/remark42"` | Image name |
 | image.tag | string | `""` | Image tag |
+| initCommand | list | `["/bin/sh"]` | Init container command |
+| initArgs | list | `["-c","find /srvtmp -maxdepth 1 -type f -delete && rm -rf /srvtmp/web && cp -R /srv/* /srvtmp && mkdir -p /srvtmp/var"]` | Init container command args |
 | imagePullSecrets | list | `[]` | Image pull secrets |
 | strategy | object | `{}` | Pod deployment strategy |
 | startupProbe | object | `see values.yaml` | Startup probe configuration |
diff --git a/charts/remark42/RELEASENOTES.md b/charts/remark42/RELEASENOTES.md
index 484ebf7b..7a41dfd4 100644
--- a/charts/remark42/RELEASENOTES.md
+++ b/charts/remark42/RELEASENOTES.md
@@ -23,4 +23,5 @@
 | 0.5.6 | v1.11.3 | Updated chart dependencies (redis 0.6.9) |
 | 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) |
 | | | |
diff --git a/charts/remark42/templates/deployment.yaml b/charts/remark42/templates/deployment.yaml
index 9e706e4f..bf1fcb96 100644
--- a/charts/remark42/templates/deployment.yaml
+++ b/charts/remark42/templates/deployment.yaml
@@ -45,8 +45,8 @@ spec:
           volumeMounts:
             - mountPath: /srvtmp
               name: remark-vol
-          command: [ "/bin/sh" ]
-          args: [ "-c", "find /srvtmp -maxdepth 1 -type f -delete && rm -rf /srvtmp/web && cp -R /srv/* /srvtmp && mkdir -p /srvtmp/var" ]
+          command: {{- toYaml .Values.initCommand | nindent 12 }}
+          args: {{- toYaml .Values.initArgs | nindent 12 }}
       containers:
         - name: {{ .Chart.Name }}
           {{- with .Values.securityContext }}
diff --git a/charts/remark42/values.yaml b/charts/remark42/values.yaml
index 540b0d7a..b1ab58de 100644
--- a/charts/remark42/values.yaml
+++ b/charts/remark42/values.yaml
@@ -8,6 +8,15 @@ image:
   # Overrides the image tag whose default is the chart appVersion.
   tag: ""
 
+## Init container command
+initCommand:
+  - /bin/sh
+
+## Init container command args
+initArgs:
+  - -c
+  - find /srvtmp -maxdepth 1 -type f -delete && rm -rf /srvtmp/web && cp -R /srv/* /srvtmp && mkdir -p /srvtmp/var
+
 ## Pull secrets and name override options
 imagePullSecrets: []
 nameOverride: ""
-- 
GitLab