{{- if .Values.setDefaultUser.enabled -}}
{{- if not (.Values.setDefaultUser.user.existingSecret) -}}
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "influxdb.fullname" . }}-auth
  labels:
    {{- include "influxdb.labels" . | nindent 4 }}
data:
  {{- if .Values.setDefaultUser.user.password }}
  influxdb-password:  {{ .Values.setDefaultUser.user.password | b64enc | quote }}
  {{- else }}
  influxdb-password: {{ randAlphaNum 10 | b64enc | quote }}
  {{- end }}
  influxdb-user: {{ .Values.setDefaultUser.user.username | b64enc | quote }}
{{- end -}}
{{- end -}}
