{{- if (include "geode.createSecret" .) }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ printf "%s-auth" (include "common.names.fullname" .) }}
  namespace: {{ .Release.Namespace | quote }}
  labels: {{- include "common.labels.standard" . | nindent 4 }}
    {{- if .Values.commonLabels }}
    {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
    {{- end }}
  {{- if .Values.commonAnnotations }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
type: Opaque
data:
  {{- if and .Values.auth.enabled (empty .Values.auth.existingSecret) }}
  username: {{ default (randAlphaNum 10) .Values.auth.username | b64enc | quote }}
  password: {{ default (randAlphaNum 10) .Values.auth.password | b64enc | quote }}
  {{- end }}
  {{- if and .Values.auth.tls.enabled (not (empty .Values.auth.tls.keystorePassword)) }}
  keystore-password: {{ .Values.auth.tls.keystorePassword | b64enc | quote }}
  {{- end }}
  {{- if and .Values.auth.tls.enabled (not (empty .Values.auth.tls.truststorePassword)) }}
  truststore-password: {{ .Values.auth.tls.truststorePassword | b64enc | quote }}
  {{- end }}
{{- end }}
