{{- if .Values.generateBasicAuth }}
apiVersion: v1
kind: Secret
metadata:
  name: basic-auth
  namespace: {{ .Release.Namespace | quote }}
  labels:
    app: {{ template "openfaas.name" . }}
    chart: {{ .Chart.Name }}-{{ .Chart.Version }}
    component: gateway
    heritage: {{ .Release.Service }}
    release: {{ .Release.Name }}
  annotations:
    "helm.sh/hook": "pre-install"
data:
  basic-auth-user: {{ "admin" | b64enc | quote }}
  # kubectl -n openfaas get secret basic-auth -o jsonpath="{.data.basic-auth-password}" | base64 --decode
  basic-auth-password: {{ randAlphaNum 12 | b64enc | quote }}
{{- end }}