{{- $domains := .Values.domains -}}
  {{- if .Values.global }}
      {{- if .Values.global.domains }}
          {{- $domains = .Values.global.domains -}}
      {{- end -}}
  {{- end -}}
apiVersion: v1
kind: ConfigMap
metadata:
  name: describoconfig
  namespace: {{ .Release.Namespace  }}
data:
  DB_HOST: {{ .Values.postgresql.fullnameOverride | quote }}
  DB_PORT: {{ .Values.postgresql.service.port | quote }}
  DB_USER: {{ .Values.postgresql.postgresqlUsername | quote }}
  DB_PASSWORD: {{ .Values.postgresql.postgresqlPassword | quote }}
  DB_DATABASE: {{ .Values.postgresql.postgresqlDatabase | quote }}
  NODE_ENV: "production"
  LOG_LEVEL: {{ .Values.environment.LOG_LEVEL | quote }}
  ADMIN_PASSWORD: {{ .Values.environment.ADMIN_PASSWORD | quote }}
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: describo-configuration-file
  namespace: {{ .Release.Namespace  }}
data:
  {{- $files := .Files }}
  {{- range tuple "nginx.conf" "type-definitions-lookup.json" "type-definitions.json" }}
  {{ . }}: |-
{{ printf "defaults/%s" . | $files.Get | indent 4 }}
  {{- end }}
  configuration.json: |-
    {
      "ui": {
          "siteName": "Sciebo - Describo Online",
          "logo": "http://www.researchobject.org/ro-crate/assets/img/ro-crate.svg",
          "login": "",
          "services": {
              "owncloud": false,
              "reva": false,
              "s3": false,
              "onedrive": false
          },
          "basePath": "/",
          "maxSessionLifetime": "86400",
          "maxEntitiesPerTemplate": "100"
      },
      "api": {
        "port": 8080,
        "periodicProcessInterval": 300,
        "applications": [
          {
              "name": "Owncloud ScieboRDS",
              "secret": "{{ .Values.global.describo.api_secret }}"
          }
        ]
      }
    }
