{{- 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 }}
type: Opaque
data:
  {{- if .Values.adminPassword }}
  password: {{ .Values.adminPassword | b64enc | quote }}
  {{- else }}
  password: {{ randAlphaNum 40 | b64enc | quote }}
  {{- end }}
{{- end }}
