{{- if or .Values.datastore.username .Values.datastore.password .Values.datastore.uri -}}
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "openfga.datastore.secretName" . }}
  labels:
    {{- include "openfga.labels" . | nindent 4 }}
data:
  {{- if .Values.datastore.password }}
  password: {{ .Values.datastore.password | b64enc | quote }}
  {{- end }}
  {{- if .Values.datastore.username }}
  username: {{ .Values.datastore.username | b64enc | quote }}
  {{- end }}
  {{- if .Values.datastore.uri }}
  uri: {{ .Values.datastore.uri | b64enc | quote }}
  {{- end }}
{{- end }}
{{- if or .Values.datastore.secondary.username .Values.datastore.secondary.password .Values.datastore.secondary.uri }}
---
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "openfga.datastore.secondary.secretName" . }}
  labels:
    {{- include "openfga.labels" . | nindent 4 }}
data:
  {{- if .Values.datastore.secondary.password }}
  password: {{ .Values.datastore.secondary.password | b64enc | quote }}
  {{- end }}
  {{- if .Values.datastore.secondary.username }}
  username: {{ .Values.datastore.secondary.username | b64enc | quote }}
  {{- end }}
  {{- if .Values.datastore.secondary.uri }}
  uri: {{ .Values.datastore.secondary.uri | b64enc | quote }}
  {{- end }}
{{- end }}
