apiVersion: v1
kind: Secret
metadata:
  name: {{ include "seafile-helm.fullname" . }}
  labels:
    {{- include "seafile-helm.labels" . | nindent 4 }}
stringData:
  ccnet.conf: |-
    [Database]
    ENGINE = {{ .Values.ccnet.database.backend }}
    HOST = {{ .Values.ccnet.database.hostname }}
    PORT = {{ .Values.ccnet.database.port }}
    USER = {{ .Values.ccnet.database.username }}
    PASSWD = {{ .Values.ccnet.database.password }}
    DB = {{ .Values.ccnet.database.name }}
    CREATE_TABLES = {{ .Values.ccnet.create_tables }}

    [General]
    SERVICE_URL = {{ .Values.ingress.external_schema }}://{{ .Values.ingress.host }}{{ .Values.ingress.seahub_path }}

    [Client]
    PORT = 13419
    UNIX_SOCKET = /tmp/seafile.sock
  gunicorn.conf: |-
    import os

    daemon = True
    workers = 5

    bind = "0.0.0.0:8000"

    pids_dir = '/tmp'
    pidfile = os.path.join(pids_dir, 'seahub.pid')

    timeout = 1200
    limit_request_line = 8190
  seafile.conf: |-
    [fileserver]
    port = 8082

    [database]
    type = {{ .Values.seafile.database.backend }}
    host = {{ .Values.seafile.database.hostname }}
    port = {{ .Values.seafile.database.port }}
    user = {{ .Values.seafile.database.username }}
    password = {{ .Values.seafile.database.password }}
    db_name = {{ .Values.seafile.database.name }}
    create_tables = {{ .Values.seafile.create_tables }}
  seahub_settings.py: |-
    SERVICE_URL = '{{ .Values.ingress.external_schema }}://{{ .Values.ingress.host }}{{ .Values.ingress.seahub_path }}'
    FILE_SERVER_ROOT = '{{ .Values.ingress.external_schema }}://{{ .Values.ingress.host }}{{ .Values.ingress.seafhttp_path }}'

    SECRET_KEY = "{{ .Values.cookie_secret }}"

    LOGGING = {
      'version': 1,
      'disable_existing_loggers': False,
      'handlers': {
        'console': {
          'class': 'logging.StreamHandler',
        },
      },
      'root': {
        'handlers': ['console'],
        'level': '{{ .Values.seahub.logLevel }}',
      },
    }

    DATABASES = {
        'default': {
            'ENGINE': '{{ .Values.seahub.database.backend }}',
            'NAME': '{{ .Values.seahub.database.name }}',
            'USER': '{{ .Values.seahub.database.username }}',
            'PASSWORD': '{{ .Values.seahub.database.password }}',
            'HOST': '{{ .Values.seahub.database.hostname }}',
            'PORT': '{{ .Values.seahub.database.port }}',
        }
    }

    {{ if .Values.seahub.cache.enabled }}
    CACHES = {
        'default': {
            'BACKEND': '{{ .Values.seahub.cache.backend }}',
            'LOCATION': [
              {{- range .Values.seahub.cache.locations -}}
              '{{ . }}',
              {{- end -}}
            ],
        },
    }
    {{ end }}

    EMAIL_HOST = '{{ .Values.seahub.email.hostname }}'
    EMAIL_PORT = {{ .Values.seahub.email.port }}
    EMAIL_USE_TLS = {{ .Values.seahub.email.port }}
    EMAIL_HOST_USER = '{{ .Values.seahub.email.username }}'
    EMAIL_HOST_PASSWORD = '{{ .Values.seahub.email.password }}'

    DEFAULT_FROM_EMAIL = '{{ .Values.seahub.email.default_from_email }}'
    SERVER_EMAIL = '{{ .Values.seahub.email.server_email }}'
  mykey.peer: |-
    {{- .Values.ccnet.key | nindent 4 -}}
