apiVersion: v1
kind: Secret
metadata:
  labels:
{{ include "dex.labels" . | indent 4 }}
  name: {{ template "dex.fullname" . }}
stringData:
  config.yaml: |-
    {{- with .Values.config }}
    issuer: {{ .issuer }}
    storage:
{{ toYaml .storage | indent 6 }}
    logger:
{{ toYaml .logger | indent 6 }}
    web:
      {{- if $.Values.https }}
      https: {{ $.Values.config.web.address }}:{{ $.Values.ports.web.containerPort }}
      tlsCert: {{ .web.tlsCert }}
      tlsKey: {{ .web.tlsKey }}
      {{- else }}
      http: {{ $.Values.config.web.address }}:{{ $.Values.ports.web.containerPort }}
      {{- end }}
      {{- if .web.allowedOrigins }}
      allowedOrigins:
      {{- range $allowedOrigin := .web.allowedOrigins }}
        - {{ $allowedOrigin | quote }}
      {{- end }}      
      {{- end }}
    {{- if $.Values.grpc }}
    grpc:
      addr: {{ $.Values.config.grpc.address }}:{{ $.Values.ports.grpc.containerPort }}
      tlsCert: {{ .grpc.tlsCert }}
      tlsKey: {{ .grpc.tlsKey }}
      tlsClientCA: {{ .grpc.tlsClientCA }}
    {{- end }}
    {{- if $.Values.telemetry }}
    telemetry:
      http: {{ $.Values.config.web.address }}:{{ $.Values.ports.telemetry.containerPort }}
    {{- end }}
    {{- if .connectors }}
    connectors:
{{ toYaml .connectors | indent 4 }}
    {{- end }}
    oauth2: {{ toYaml .oauth2 | nindent 6 }}
    {{- if .staticClients }}
    staticClients:
{{ toYaml .staticClients | indent 4 }}
    {{- end }}
    enablePasswordDB: {{ .enablePasswordDB }}
    {{- if .staticPasswords }}
    staticPasswords:
{{ toYaml .staticPasswords | indent 4 }}
    {{- end }}
    {{- if .expiry }}
    expiry:
{{ toYaml .expiry | indent 6 }}
    {{- end }}
    {{- if .frontend }}
    frontend: {{ toYaml .frontend | nindent 6 }}
    {{- end }}
    {{- end }}
