From cfabe71248ea1c9ebb9958af44a9e83b12ff091e Mon Sep 17 00:00:00 2001
From: Andrej Shadura <andrew.shadura@collabora.co.uk>
Date: Wed, 27 Apr 2022 16:55:39 +0200
Subject: [PATCH 1/3] Add labels to the backend configmap

Signed-off-by: Andrej Shadura <andrew.shadura@collabora.co.uk>
---
 helm/open-build-service/charts/backend/templates/configmap.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/helm/open-build-service/charts/backend/templates/configmap.yaml b/helm/open-build-service/charts/backend/templates/configmap.yaml
index 5eb34bb349..c80fc6aa30 100644
--- a/helm/open-build-service/charts/backend/templates/configmap.yaml
+++ b/helm/open-build-service/charts/backend/templates/configmap.yaml
@@ -2,6 +2,8 @@ apiVersion: v1
 kind: ConfigMap
 metadata:
   name: {{ include "backend.fullname" . }}-config
+  labels:
+    {{- include "backend.labels" . | nindent 4 }}
 data:
   BSConfig.local.pm: {{
       printf "%s\n%s\n1;\n" "$ipaccess->{\".*\"} = \"rw,worker\";" (
-- 
GitLab


From c2365630a946bde2d1bd046cd9897c4542f696d6 Mon Sep 17 00:00:00 2001
From: Andrej Shadura <andrew.shadura@collabora.co.uk>
Date: Wed, 27 Apr 2022 16:56:17 +0200
Subject: [PATCH 2/3] Add a loglevel setting for the frontend

Signed-off-by: Andrej Shadura <andrew.shadura@collabora.co.uk>
---
 .../charts/frontend/templates/deployment.yaml                   | 2 ++
 helm/open-build-service/charts/frontend/values.yaml             | 1 +
 2 files changed, 3 insertions(+)

diff --git a/helm/open-build-service/charts/frontend/templates/deployment.yaml b/helm/open-build-service/charts/frontend/templates/deployment.yaml
index 77a8e1a0d8..4564b1889e 100644
--- a/helm/open-build-service/charts/frontend/templates/deployment.yaml
+++ b/helm/open-build-service/charts/frontend/templates/deployment.yaml
@@ -38,6 +38,8 @@ spec:
             {{- if .Values.global.frontend }}
             - name: OBS_FRONTEND_WORKERS
               value: {{ default 4 .Values.global.frontend.workers | quote }}
+            - name: OBS_LOG_LEVEL
+              value: {{ default "info" .Values.global.frontend.loglevel | quote }}
             {{- end }}
             - name: OBS_MEMCACHE_HOST
               value: {{ include "frontend.memcached.fullname" . | quote }}
diff --git a/helm/open-build-service/charts/frontend/values.yaml b/helm/open-build-service/charts/frontend/values.yaml
index 90f9c2be52..35a9c203a9 100644
--- a/helm/open-build-service/charts/frontend/values.yaml
+++ b/helm/open-build-service/charts/frontend/values.yaml
@@ -17,6 +17,7 @@ fullnameOverride: ""
 global:
   frontend: {}
     # workers: 8
+    # loglevel: info
   backend: {}
     # host: backend
 
-- 
GitLab


From b9e88678d679e3a9a684ac2eb45f50d21aea9cef Mon Sep 17 00:00:00 2001
From: Andrej Shadura <andrew.shadura@collabora.co.uk>
Date: Wed, 27 Apr 2022 09:54:57 +0200
Subject: [PATCH 3/3] Add more settings, including SSO and msmtp

Signed-off-by: Andrej Shadura <andrew.shadura@collabora.co.uk>
---
 .../charts/frontend/templates/deployment.yaml | 20 +++++++++++++++++++
 .../frontend/templates/email-secret.yaml      | 11 ++++++++++
 .../charts/frontend/templates/sso-secret.yaml | 11 ++++++++++
 helm/open-build-service/values.yaml           | 11 ++++++++++
 4 files changed, 53 insertions(+)
 create mode 100644 helm/open-build-service/charts/frontend/templates/email-secret.yaml
 create mode 100644 helm/open-build-service/charts/frontend/templates/sso-secret.yaml

diff --git a/helm/open-build-service/charts/frontend/templates/deployment.yaml b/helm/open-build-service/charts/frontend/templates/deployment.yaml
index 4564b1889e..2f1082a694 100644
--- a/helm/open-build-service/charts/frontend/templates/deployment.yaml
+++ b/helm/open-build-service/charts/frontend/templates/deployment.yaml
@@ -88,6 +88,16 @@ spec:
               mountPath: /tmp
             - name: frontend-logs
               mountPath: /obs/src/api/log
+            {{- if (or .Values.global.frontend.msmtprc .Values.global.frontend.msmtprcExistingSecret) }}
+            - name: frontend-email-secret
+              mountPath: /run/secrets/msmtprc
+              subPath: msmtprc
+            {{- end }}
+            {{- if (or .Values.global.frontend.ssoauth .Values.global.frontend.ssoauthExistingSecret) }}
+            - name: frontend-sso-secret
+              mountPath: /run/secrets/ssoauth
+              subPath: ssoauth
+            {{- end }}
         - name: {{ .Chart.Name }}-weblog
           image: busybox
           args:
@@ -132,6 +142,16 @@ spec:
           emptyDir: {}
         - name: frontend-logs
           emptyDir: {}
+        {{- if (or .Values.global.frontend.msmtprc .Values.global.frontend.msmtprcExistingSecret) }}
+        - name: frontend-email-secret
+          secret:
+            secretName: {{ .Values.global.frontend.msmtprcExistingSecret | default (printf "%s-email" (include "frontend.fullname" .)) }}
+        {{- end }}
+        {{- if (or .Values.global.frontend.ssoauth .Values.global.frontend.ssoauthExistingSecret) }}
+        - name: frontend-sso-secret
+          secret:
+            secretName: {{ .Values.global.frontend.ssoauthExistingSecret | default (printf "%s-sso" (include "frontend.fullname" .)) }}
+        {{- end }}
       {{- with .Values.nodeSelector }}
       nodeSelector:
         {{- toYaml . | nindent 8 }}
diff --git a/helm/open-build-service/charts/frontend/templates/email-secret.yaml b/helm/open-build-service/charts/frontend/templates/email-secret.yaml
new file mode 100644
index 0000000000..cf81096220
--- /dev/null
+++ b/helm/open-build-service/charts/frontend/templates/email-secret.yaml
@@ -0,0 +1,11 @@
+{{- if (and .Values.global.frontend.msmtprc (not .Values.global.frontend.msmtprcExistingSecret)) -}}
+apiVersion: v1
+kind: Secret
+type: Opaque
+metadata:
+  name: {{ include "frontend.fullname" . }}-email
+  labels:
+    {{- include "frontend.labels" . | nindent 4 }}
+data:
+  msmtprc: {{ default "" .Values.global.frontend.msmtprc | b64enc | quote }}
+{{- end }}
diff --git a/helm/open-build-service/charts/frontend/templates/sso-secret.yaml b/helm/open-build-service/charts/frontend/templates/sso-secret.yaml
new file mode 100644
index 0000000000..0f6b39cffe
--- /dev/null
+++ b/helm/open-build-service/charts/frontend/templates/sso-secret.yaml
@@ -0,0 +1,11 @@
+{{- if (and .Values.global.frontend.ssoauth (not .Values.global.frontend.ssoauthExistingSecret)) -}}
+apiVersion: v1
+kind: Secret
+type: Opaque
+metadata:
+  name: {{ include "frontend.fullname" . }}-sso
+  labels:
+    {{- include "frontend.labels" . | nindent 4 }}
+data:
+  ssoauth: {{ default "" .Values.global.frontend.ssoauth | toYaml | b64enc | quote }}
+{{- end }}
diff --git a/helm/open-build-service/values.yaml b/helm/open-build-service/values.yaml
index e8c1f8e7f0..593e362c54 100644
--- a/helm/open-build-service/values.yaml
+++ b/helm/open-build-service/values.yaml
@@ -24,6 +24,17 @@ global:
   frontend:
     workers: 4
     # host: frontend
+    # msmtprc: |
+    #   ...
+    # ssoauth:
+    #   fdo-gitlab:
+    #     strategy: gitlab
+    #     description: Freedesktop.org GitLab
+    #     scope: read_user openid profile email
+    #     client_id: hexhexhexhex
+    #     client_secret: hexhexhexhex
+    #     client_options:
+    #       site: https://gitlab.freedesktop.org/api/v4
   backend: {}
     # host: backend
     # extraConfig: |
-- 
GitLab