{{- if (not .Values.existingSecret) -}}
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "influxdb.fullname" . }}
  labels: 
    {{- include "influxdb.labels" . | nindent 4 }}
type: Opaque
data:
  admin-user-password: {{ ternary (randAlphaNum 10) .Values.adminUser.pwd (empty .Values.adminUser.pwd) | b64enc | quote }}
  {{- if .Values.user.name }}
  user-password: {{ ternary (randAlphaNum 10) .Values.user.pwd (empty .Values.user.pwd) | b64enc | quote }}
  {{- end }}
  {{- if .Values.readUser.name }}
  read-user-password: {{ ternary (randAlphaNum 10) .Values.readUser.pwd (empty .Values.readUser.pwd) | b64enc | quote }}
  {{- end }}
  {{- if .Values.writeUser.name }}
  write-user-password: {{ ternary (randAlphaNum 10) .Values.writeUser.pwd (empty .Values.writeUser.pwd) | b64enc | quote }}
  {{- end }}
{{- end }}
