{{- if not .Values.graylog.existingRootSecret }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ template "graylog.fullname" . }}
  labels:
{{ include "graylog.metadataLabels" . | indent 4 }}
type: Opaque
data:
  graylog-root-username: {{ .Values.graylog.rootUsername | b64enc | quote }}
  {{- if .Values.graylog.rootPassword }}
  graylog-password-secret: {{ .Values.graylog.rootPassword | b64enc | quote }}
  graylog-password-sha2: {{ .Values.graylog.rootPassword | sha256sum | b64enc | quote }}
  {{- else }}
  {{- $randpass := randAlphaNum 16 }}
  graylog-password-secret: {{ $randpass | b64enc | quote }}
  graylog-password-sha2: {{ $randpass | sha256sum | b64enc | quote }}
  {{- end }}
{{- end }}
