environments:
  dev-keycloak:
    values:
      - version: 0.0.1
      - env.d/{{ .Environment.Name }}/values.secrets.yaml
  dev:
    values:
      - version: 0.0.1
      - env.d/{{ .Environment.Name }}/values.secrets.yaml

repositories:
- name: bitnami
  url: registry-1.docker.io/bitnamicharts
  oci: true
- name: livekit
  url: https://helm.livekit.io

releases:
  - name: postgres
    installed: {{ regexMatch "^dev.*" .Environment.Name | toYaml }}
    missingFileHandler: Warn
    namespace: {{ .Namespace }}
    chart: bitnami/postgresql
    version: 13.1.5
    values:
      - auth:
          username: dinum
          password: pass
          database: meet
      - tls:
          enabled: true
          autoGenerated: true

  - name: keycloak
    installed: {{ eq .Environment.Name "dev-keycloak" | toYaml }}
    missingFileHandler: Warn
    namespace: {{ .Namespace }}
    chart: bitnami/keycloak
    version: 17.3.6
    values:
      - postgresql:
          auth:
            username: keycloak
            password: keycloak
            database: keycloak
      - extraEnvVars:
          - name: KEYCLOAK_EXTRA_ARGS
            value: "--import-realm"
          - name: KC_HOSTNAME_URL
            value: https://keycloak.127.0.0.1.nip.io
      - extraVolumes:
          - name: import
            configMap:
              name: meet-keycloak
      - extraVolumeMounts:
          - name: import
            mountPath: /opt/bitnami/keycloak/data/import/
      - auth:
          adminUser: su
          adminPassword: su
      - proxy: edge
      - ingress:
          enabled: true
          hostname: keycloak.127.0.0.1.nip.io
      - extraDeploy:
        - apiVersion: v1
          kind: ConfigMap
          metadata:
            name: meet-keycloak
          data:
            meet.json: |
{{ readFile "../../docker/auth/realm.json" | replace "http://localhost:3200" "https://meet.127.0.0.1.nip.io" | indent 14 }}

  - name: minio
    installed: {{ regexMatch "^dev.*" .Environment.Name | toYaml }}
    namespace: {{ .Namespace }}
    missingFileHandler: Warn
    chart: bitnami/minio
    version: 12.10.10
    values:
      - auth:
          rootUser: meet
          rootPassword: password
      - provisioning:
          enabled: true
          buckets:
            - name: meet-media-storage
              versioning: true
      - ingress:
          enabled: true
          hostname: minio-console.127.0.0.1.nip.io
          servicePort: 9001
          annotations:
            nginx.ingress.kubernetes.io/proxy-body-size: "0"
            kubernetes.io/ingress.class: nginx
        extraVolumes:
          - name: mkcert
            secret:
              secretName: mkcert
        extraVolumeMounts:
          - mountPath: /certs/CAs/
            name: mkcert

  - name: redis
    installed: {{ regexMatch "^dev.*" .Environment.Name | toYaml }}
    missingFileHandler: Warn
    namespace: {{ .Namespace }}
    chart: bitnami/redis
    version: 18.19.2
    values:
      - auth:
          password: pass
        architecture: standalone

  - name: extra
    installed: {{ regexMatch "^dev.*" .Environment.Name | toYaml }}
    missingFileHandler: Warn
    namespace: {{ .Namespace }}
    chart: ./extra
    secrets:
      - env.d/{{ .Environment.Name }}/secrets.enc.yaml
    values:
    - env.d/{{ .Environment.Name }}/values.meet.yaml.gotmpl
    - addRedirect: {{ .Values | get "addRedirect" "False" }}
      enablePermanentRedirect: {{ .Values | get "enablePermanentRedirect" "False"}}
      oldDomain: {{ .Values | get "oldDomain" "demo.com" }}
      newDomain: {{ .Values | get "newDomain" "demo.com" }}

  - name: meet
    version: {{ .Values.version }}
    namespace: {{ .Namespace }}
    missingFileHandler: Warn
    chart: ./meet
    values:
      - env.d/{{ .Environment.Name }}/values.meet.yaml.gotmpl
      - env.d/{{ .Environment.Name }}/values.secrets.yaml
    secrets:
      - env.d/{{ .Environment.Name }}/secrets.enc.yaml

  - name: livekit
    installed: {{ regexMatch "^dev.*" .Environment.Name | toYaml }}
    missingFileHandler: Warn
    namespace: {{ .Namespace }}
    chart: livekit/livekit-server
    values:
      - env.d/{{ .Environment.Name }}/values.livekit.yaml.gotmpl
      - env.d/{{ .Environment.Name }}/values.secrets.yaml
    secrets:
      - env.d/{{ .Environment.Name }}/secrets.enc.yaml

  - name: livekit-egress
    installed: {{ regexMatch "^dev.*" .Environment.Name | toYaml }}
    missingFileHandler: Warn
    namespace: {{ .Namespace }}
    chart: livekit/egress
    values:
      - env.d/{{ .Environment.Name }}/values.egress.yaml.gotmpl
      - env.d/{{ .Environment.Name }}/values.secrets.yaml
    secrets:
      - env.d/{{ .Environment.Name }}/secrets.enc.yaml
