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

{{- if (include "solr.createSecret" .) }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "common.names.fullname" . }}
  labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
    app.kubernetes.io/component: solr
  {{- if .Values.commonAnnotations }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
  namespace: {{ include "common.names.namespace" . | quote }}
type: Opaque
data:
  solr-password: {{ include "common.secrets.passwords.manage" (dict "secret" (include "common.names.fullname" .) "key" "solr-password" "providedValues" (list "auth.adminPassword") "context" $) }}
{{- end }}
{{- if (include "solr.createTlsPasswordsSecret" .) }}
---
apiVersion: v1
kind: Secret
metadata:
  name: {{ printf "%s-tls-pass" (include "common.names.fullname" .)| trunc 63 | trimSuffix "-" }}
  labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
    app.kubernetes.io/component: solr
  {{- if .Values.commonAnnotations }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
  namespace: {{ include "common.names.namespace" . | quote }}
type: Opaque
data:
  keystore-password: {{ default (randAlphaNum 10) .Values.tls.keystorePassword | b64enc | quote }}
  truststore-password: {{ default (randAlphaNum 10) .Values.tls.truststorePassword | b64enc | quote }}
{{- end }}
