{{- if (include "argo-workflows.controller.persistence.enabled" .) }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "argo-workflows.controller.database.username.secret" . }}
  namespace: {{ .Release.Namespace | quote }}
  labels: {{- include "common.labels.standard" . | nindent 4 }}
    app.kubernetes.io/component: controller
    app.kubernetes.io/part-of: argo-workflows
    {{- if .Values.commonLabels }}
    {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
    {{- end }}
  {{- if .Values.commonAnnotations }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
type: Opaque
data:
  username: {{ include "argo-workflows.controller.database.username" . | b64enc }}
  {{- if and .Values.externalDatabase.enabled (not .Values.externalDatabase.existingSecret) }}
  database-password: {{ .Values.externalDatabase.password | b64enc }}
  {{- end }}
{{- end }}
