{{- if and .Values.htpasswdFile.enabled (not .Values.htpasswdFile.existingSecret) }}
apiVersion: v1
kind: Secret
metadata:
  labels:
    app: {{ template "oauth2-proxy.name" . }}
{{- include "oauth2-proxy.labels" . | indent 4 }}
  name: {{ template "oauth2-proxy.fullname" . }}-htpasswd-file
  namespace: {{ template "oauth2-proxy.namespace" $ }}
type: Opaque
stringData:
  users.txt: |-
    {{- range $entries := .Values.htpasswdFile.entries }}
    {{ $entries }}
    {{- end -}}
{{- end }}
