Skip to content

Commit

Permalink
Merge pull request #11 from sonroyaalmerol/dev
Browse files Browse the repository at this point in the history
Chart: add multi-line existing secrets and multiple existing secrets support
  • Loading branch information
sonroyaalmerol committed May 21, 2024
2 parents 2f98a45 + f1ff33f commit e094347
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion charts/sogo/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: sogo
version: 0.1.5
version: 0.1.6
description: A helm chart for the docker-sogo docker image
type: application
keywords:
Expand Down
3 changes: 2 additions & 1 deletion charts/sogo/ci/existing-secrets-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ sogo:
SOGoLanguage: English
SOGoTimeZone: America/Montreal
WOWorkersCount: 5
existingSecrets: test-secret
existingSecrets:
- test-secret
28 changes: 18 additions & 10 deletions charts/sogo/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,12 @@ spec:
- name: {{ template "sogo.fullname" . }}-tmp
mountPath: /secrets
{{- if .Values.sogo.existingSecrets }}
- name: existing-secrets
mountPath: /existing-secrets
{{- range .Values.sogo.existingSecrets }}
- name: {{ printf "existing-secrets-%s" (kebabcase .) }}
mountPath: {{ printf "/existing-secrets/%s" (kebabcase .) }}
readOnly: true
{{- end }}
{{- end }}
command:
- "sh"
- "-c"
Expand All @@ -239,28 +241,32 @@ spec:
touch "$tmp_script"
cat << 'EOF' > "$tmp_script"
#!/bin/sh
#!/bin/bash
output_file="/secrets/existing-secrets.yaml"
> "$output_file"
# Loop through each file in the directory
for file in /existing-secrets/*; do
# Find all files within the existing-secrets directory and its subdirectories
find /existing-secrets -type f | while read -r file; do
# Get the filename without the directory path
filename=$(basename "$file")
# Read the content of the file
# Read the content of the file and indent each line with two spaces
content=$(cat "$file")
# Append the filename and content to the YAML file
# Append the filename and content to the YAML file if the content is not empty
if [ -n "$content" ]; then
echo "$filename: $content" >> "$output_file"
echo "$filename: |-" >> "$output_file"
while IFS= read -r line; do
echo " $line" >> "$output_file"
done <<< "$content"
fi
done
EOF
chmod +x "$tmp_script"
# Generation of config file
sh "$tmp_script"
bash "$tmp_script"
{{- if or .Values.mariadb.enabled (eq (include "sogo.db.parsed.type" .) "mysql") }}
- name: mariadb-isalive
Expand Down Expand Up @@ -358,9 +364,11 @@ spec:
secretName: {{ template "sogo.fullname" . }}-secret
{{- end }}
{{- if .Values.sogo.existingSecrets }}
- name: existing-secrets
{{- range .Values.sogo.existingSecrets }}
- name: {{ printf "existing-secrets-%s" (kebabcase .) }}
secret:
secretName: {{ .Values.sogo.existingSecrets }}
secretName: {{ . }}
{{- end }}
{{- end }}
- name: {{ template "sogo.fullname" . }}-tmp
emptyDir: {}
Expand Down
4 changes: 2 additions & 2 deletions charts/sogo/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ sogo:
# OCSStoreURL: "mysql://sogo:pass@db:3306/sogo/sogo_store"
# OCSAclURL: "mysql://sogo:pass@db:3306/sogo/sogo_acl"

# Name of Secret containing the configurations
existingSecrets:
# Array of secret names containing the configurations
existingSecrets: []

## SOGo Custom Theming
## NOTE: SOGoUIxDebugEnabled is automatically set to YES when only .sogo.theme.js is set
Expand Down

0 comments on commit e094347

Please sign in to comment.