{{- if .Values.datastore.enabled}}
apiVersion: kamaji.clastix.io/v1alpha1
kind: DataStore
metadata:
  name: {{ include "datastore.fullname" . }}
  annotations:
    "helm.sh/hook": pre-install
  labels:
    {{- include "datastore.labels" . | nindent 4 }}
spec:
  driver: {{ .Values.datastore.driver }}
  endpoints:
    {{- include "datastore.endpoints" . | indent 4 }}
{{- if (and .Values.datastore.basicAuth.usernameSecret.name .Values.datastore.basicAuth.passwordSecret.name) }}
  basicAuth:
    username:
      secretReference:
        {{- .Values.datastore.basicAuth.usernameSecret | toYaml | nindent 8 }}
    password:
      secretReference:
        {{- .Values.datastore.basicAuth.passwordSecret | toYaml | nindent 8 }}
{{- end }}
  tlsConfig:
    certificateAuthority:
      {{- include "datastore.certificateAuthority" . | indent 6 }}
    clientCertificate:
      {{- include "datastore.clientCertificate" . | indent 6 }}
{{- end}}
