{{- if and .Values.admin.enabled (not .Values.admin.existingSecret) }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ template "pihole.password-secret" . }}
  labels:
    app: {{ template "pihole.name" . }}
    chart: {{ template "pihole.chart" . }}
    heritage: {{ .Release.Service }}
    release: {{ .Release.Name }}
  {{- with .Values.admin.annotations }}
  annotations:
{{ toYaml . | indent 4 }}
  {{- end }}
type: Opaque
data:
  {{- if .Values.adminPassword }}
  password: {{ .Values.adminPassword | b64enc | quote }}
  {{- else }}
  password: {{ randAlphaNum 40 | b64enc | quote }}
  {{- end }}
{{- end }}
