From 4cad3bde52e0ab8d46f880b75728e53f2635ddc8 Mon Sep 17 00:00:00 2001
From: Guillermo Facundo Colunga <guillermo.facundo.colunga@cern.ch>
Date: Tue, 21 Jan 2025 13:59:37 +0100
Subject: [PATCH] [MONIT-4106] fluentbit/logs: add support for user provided
 lua scripts

While doing trying to mimic the OpenShift logging setup with the current
Helm chart we noticed that they were using the lua scripts input from
the fluent bit official Helm chart. In our case this was not possible
and had to be done by adding secrets one by one.

We agreed to mimic this behaviour and had our own helm chart have the
option to add lua scripts to the fluent bit via helm chart values.

This commit modifies the configmap used to create the lua script that
we required for the timestampt in such a way that now it creates this
first lua script but also creates any other provided by the users via
the values of the helm chart.

Reported-at: https://its.cern.ch/jira/browse/MONIT-4106
Signed-off-by: Guillermo Facundo Colunga <guillermo.facundo.colunga@gmail.com>
Signed-off-by: Guillermo Facundo Colunga <guillermo.facundo.colunga@cern.ch>
---
 .../{scripts.yaml => configmap-luascripts.yaml}            | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
 rename templates/fluentbit-logs/{scripts.yaml => configmap-luascripts.yaml} (74%)

diff --git a/templates/fluentbit-logs/scripts.yaml b/templates/fluentbit-logs/configmap-luascripts.yaml
similarity index 74%
rename from templates/fluentbit-logs/scripts.yaml
rename to templates/fluentbit-logs/configmap-luascripts.yaml
index 954535c..916c74d 100644
--- a/templates/fluentbit-logs/scripts.yaml
+++ b/templates/fluentbit-logs/configmap-luascripts.yaml
@@ -12,4 +12,9 @@ data:
       record['timestamp'] = exp_sec * 1000
       return 2, timestamp, record
     end
-{{- end -}}
+  {{- if .Values.logs.fluentbit.luaScripts -}}
+  {{ range $key, $value := .Values.logs.fluentbit.luaScripts }}
+  {{ $key }}: {{ $value | quote }}
+  {{ end }}
+  {{ end }}
+{{- end -}}
\ No newline at end of file
-- 
GitLab