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

{{- $kafkaProtocol := ternary .Values.kafka.listeners.client.protocol .Values.externalKafka.listener.protocol .Values.kafka.enabled -}}
{{- if and (not .Values.kafka.enabled) (contains "SASL" $kafkaProtocol) (empty .Values.externalKafka.sasl.existingSecret) }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "schema-registry.secretName" . }}
  namespace: {{ include "common.names.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:
  client-passwords: {{ include "common.secrets.passwords.manage" (dict "secret" (include "common.names.fullname" .) "key" "client-password" "providedValues" (list "externalKafka.sasl.password" ) "context" $) }}
{{- end }}
