wekan / charts

Wekan Helm Charts to deploy to Kubernetes
MIT License
2 stars 15 forks source link

[Fix] Secrets handling in helm chart #25

Closed markksuite closed 10 months ago

markksuite commented 10 months ago

Issue

Current templates/secret.yaml runs Secret api on every item in secretEnv. If you have several secretEnv, for example:

secretEnv:
  - name: "MAIL_SERVICE_USER"
    value: "123"    
  - name: "MAIL_SERVICE_PASSWORD"
    value: "321"

It will run run same resource two times and add only MAIL_SERVICE_PASSWORD (last) secret.

Fix

Move range loop and add "-" to avoid newlines:

{{ if .Values.secretEnv }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ template "wekan.fullname" $ }}-secret
type: Opaque
data:
{{- range $key := .Values.secretEnv -}}
{{ if $key.value }}
{{ $key.name | indent 2 }}: {{ $key.value | b64enc }}
{{- end }}
{{- end }}
{{ end }}

Original code:

{{ if .Values.secretEnv }}
{{- range $key := .Values.secretEnv }}
{{ if $key.value }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ template "wekan.fullname" $ }}-secret
type: Opaque
data:
{{ $key.name | indent 2 }}: {{ $key.value | b64enc }}
{{ end }}
{{- end}}
{{ end }}
xet7 commented 10 months ago

@markksuite

Please send PR. Thanks!