_configuration.tpl 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. {{- define "planka.configuration" -}}
  2. {{- $fullname := (include "ix.v1.common.lib.chart.names.fullname" $) -}}
  3. {{- $secretKey := randAlphaNum 32 -}}
  4. {{- with (lookup "v1" "Secret" .Release.Namespace (printf "%s-planka" $fullname)) -}}
  5. {{- $secretKey = ((index .data "SECRET_KEY") | b64dec) -}}
  6. {{- end -}}
  7. {{- $dbHost := (printf "%s-postgres" $fullname) -}}
  8. {{- $dbUser := "planka" -}}
  9. {{- $dbName := "planka" -}}
  10. {{- $dbPass := (randAlphaNum 32) -}}
  11. {{- with (lookup "v1" "Secret" .Release.Namespace (printf "%s-postgres-creds" $fullname)) -}}
  12. {{- $dbPass = ((index .data "POSTGRES_PASSWORD") | b64dec) -}}
  13. {{- end -}}
  14. {{- $dbURL := (printf "%s:%s@%s:5432/%s?sslmode=disable" $dbUser $dbPass $dbHost $dbName) -}}
  15. {{/* Temporary set dynamic db details on values,
  16. so we can print them on the notes */}}
  17. {{- $_ := set .Values "plankaDbPass" $dbPass -}}
  18. {{- $_ := set .Values "plankaDbHost" $dbHost }}
  19. secret:
  20. planka:
  21. enabled: true
  22. data:
  23. SECRET_KEY: {{ $secretKey }}
  24. DATABASE_URL: {{ printf "postgresql://%s" $dbURL }}
  25. postgres-creds:
  26. enabled: true
  27. data:
  28. POSTGRES_USER: {{ $dbUser }}
  29. POSTGRES_DB: {{ $dbName }}
  30. POSTGRES_PASSWORD: {{ $dbPass }}
  31. POSTGRES_HOST: {{ $dbHost }}
  32. POSTGRES_URL: {{ printf "postgres://%s" $dbURL }}
  33. {{- if and
  34. (not (hasPrefix "http://" .Values.plankaConfig.baseURL))
  35. (not (hasPrefix "https://" .Values.plankaConfig.baseURL)) -}}
  36. {{- fail "Planka - Expected [Base URL] to start with [http://] or [https://]" -}}
  37. {{- end }}
  38. configmap:
  39. planka:
  40. enabled: true
  41. data:
  42. NODE_ENV: production
  43. BASE_URL: {{ .Values.plankaConfig.baseURL }}
  44. TRUST_PROXY: {{ ternary "1" "0" .Values.plankaConfig.trustProxy | quote }}
  45. {{- end -}}