#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
{{- if .Values.option.autoCreateSecret }}
---
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "devlake.mysql.secret" . }}
stringData:
{{- if (eq .Values.option.database "mysql") }}
  MYSQL_USER: "{{ .Values.mysql.username }}"
  MYSQL_PASSWORD: "{{ .Values.mysql.password }}"
  MYSQL_DATABASE: "{{ .Values.mysql.database }}"
  MYSQL_ROOT_PASSWORD: "{{ .Values.mysql.rootPassword }}"
  DB_URL: "{{ include "database.url" . }}"
  MYSQL_URL: "{{ include "mysql.server" . }}:{{ include "mysql.port" . }}"
#{{- else if (eq .Values.option.database "pgsql")}}
#  POSTGRES_USER: "{{ .Values.pgsql.username }}"
#  POSTGRES_PASSWORD: "{{ .Values.pgsql.password }}"
#  POSTGRES_DB: "{{ .Values.pgsql.database }}"
#  DB_URL: "{{ include "database.url" . }}"
{{- end }}
{{- end }}

{{- if and .Values.ui.basicAuth.enabled .Values.ui.basicAuth.autoCreateSecret }}
---
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "devlake.ui.auth.secret" . }}
stringData:
  ADMIN_USER: "{{ .Values.ui.basicAuth.user }}"
  ADMIN_PASS: "{{ .Values.ui.basicAuth.password }}"
{{- end }}

{{- if .Values.lake.encryptionSecret.autoCreateSecret }}
---
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "devlake.lake.encryption.secret" . }}
stringData:
  ENCRYPTION_SECRET: {{ .Values.lake.encryptionSecret.secret }}
{{- end }}
