Skip to content

Commit

Permalink
Merge pull request #12 from sonroyaalmerol/dev
Browse files Browse the repository at this point in the history
chart: add option to parse existingSecrets as yaml
  • Loading branch information
sonroyaalmerol authored May 21, 2024
2 parents e094347 + 66b206a commit 5f0cf8c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 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.6
version: 0.1.7
description: A helm chart for the docker-sogo docker image
type: application
keywords:
Expand Down
2 changes: 1 addition & 1 deletion charts/sogo/ci/existing-secrets-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ sogo:
SOGoTimeZone: America/Montreal
WOWorkersCount: 5
existingSecrets:
- test-secret
- name: test-secret
25 changes: 20 additions & 5 deletions charts/sogo/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,12 @@ spec:
mountPath: /secrets
{{- if .Values.sogo.existingSecrets }}
{{- range .Values.sogo.existingSecrets }}
- name: {{ printf "existing-secrets-%s" (kebabcase .) }}
mountPath: {{ printf "/existing-secrets/%s" (kebabcase .) }}
- name: {{ printf "existing-secrets-%s" (kebabcase .name) }}
{{- if .yaml }}
mountPath: {{ printf "/existing-secrets/%s__yaml" (kebabcase .name) }}
{{- else }}
mountPath: {{ printf "/existing-secrets/%s" (kebabcase .name) }}
{{- end }}
readOnly: true
{{- end }}
{{- end }}
Expand All @@ -249,13 +253,24 @@ spec:
# Loop through each file in the directory
# Find all files within the existing-secrets directory and its subdirectories
find /existing-secrets -type f | while read -r file; do
is_yaml=false
# Get the filename without the directory path
filename=$(basename "$file")
if [[ $filename == *"__yaml" ]]; then
is_yaml=true
filename="${filename/__yaml/}"
fi
# 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 if the content is not empty
if [ -n "$content" ]; then
echo "$filename: |-" >> "$output_file"
if [ "$is_yaml" = true ]; then
echo "$filename:" >> "$output_file"
else
echo "$filename: |-" >> "$output_file"
fi
while IFS= read -r line; do
echo " $line" >> "$output_file"
done <<< "$content"
Expand Down Expand Up @@ -365,9 +380,9 @@ spec:
{{- end }}
{{- if .Values.sogo.existingSecrets }}
{{- range .Values.sogo.existingSecrets }}
- name: {{ printf "existing-secrets-%s" (kebabcase .) }}
- name: {{ printf "existing-secrets-%s" (kebabcase .name) }}
secret:
secretName: {{ . }}
secretName: {{ .name }}
{{- end }}
{{- end }}
- name: {{ template "sogo.fullname" . }}-tmp
Expand Down
6 changes: 5 additions & 1 deletion charts/sogo/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,12 @@ sogo:
# OCSStoreURL: "mysql://sogo:pass@db:3306/sogo/sogo_store"
# OCSAclURL: "mysql://sogo:pass@db:3306/sogo/sogo_acl"

# Array of secret names containing the configurations
# Array of secrets containing the configurations
existingSecrets: []
# - name: secretName
# - name: secretName2
# yaml: true
### having yaml set to true would parse the secret as a yaml file

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

0 comments on commit 5f0cf8c

Please sign in to comment.