{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}

{{- if .Values.db.enableSsl }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ printf "%s-certs" (include "common.names.fullname" .) }}
  namespace: {{ .Release.Namespace | quote }}
  labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
  {{- if .Values.commonAnnotations }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
type: Opaque
data:
  {{- if not (empty .Values.db.ssl.clientKey) }}
  server_key.pem: {{ .Values.db.ssl.clientKey | b64enc | quote }}
  {{- end }}
  {{- if not (empty .Values.db.ssl.clientCertificate) }}
  server_certificate.pem: {{ .Values.db.ssl.clientCertificate | b64enc | quote }}
  {{- end }}
  {{- if not (empty .Values.db.ssl.caCertificate) }}
  ca_certificate.pem: {{ .Values.db.ssl.caCertificate | b64enc | quote }}
  {{- end }}
{{- end }}
