apiVersion: v1
kind: Secret
metadata:
  name: {{ include "chart.resourceNamePrefix" . }}hub-config
type: Opaque
stringData:
  hub.yaml: |-
    restrictedHTTPClient: {{ .Values.restrictedHTTPClient }}
    log:
      level: {{ .Values.log.level }}
      pretty: {{ .Values.log.pretty }}
    db:
      host: {{ default (printf "%s-postgresql.%s" .Release.Name .Release.Namespace) .Values.db.host }}
      port: {{ .Values.db.port }}
      database: {{ .Values.db.database }}
      user: {{ .Values.db.user }}
      password: {{ .Values.db.password }}
    email:
      fromName: {{ .Values.email.fromName }}
      from: {{ .Values.email.from }}
      replyTo: {{ .Values.email.replyTo }}
      smtp:
        auth: {{ .Values.email.smtp.auth }}
        host: {{ .Values.email.smtp.host }}
        port: {{ .Values.email.smtp.port }}
        username: {{ .Values.email.smtp.username }}
        password: {{ .Values.email.smtp.password }}
    images:
      store: {{ .Values.images.store }}
    server:
      allowPrivateRepositories: {{ .Values.hub.server.allowPrivateRepositories }}
      baseURL: {{ .Values.hub.server.baseURL }}
      shutdownTimeout: {{ .Values.hub.server.shutdownTimeout }}
      addr: 0.0.0.0:8000
      metricsAddr: 0.0.0.0:8001
      shutdownTimeout: 30s
      webBuildPath: ./web
      widgetBuildPath: ./widget
      motd: {{ .Values.hub.server.motd }}
      motdSeverity: {{ .Values.hub.server.motdSeverity }}
      basicAuth:
        enabled: {{ .Values.hub.server.basicAuth.enabled }}
        username: {{ .Values.hub.server.basicAuth.username }}
        password: {{ .Values.hub.server.basicAuth.password }}
      cookie:
        hashKey: {{ .Values.hub.server.cookie.hashKey }}
        secure: {{ .Values.hub.server.cookie.secure }}
      csrf:
        authKey: {{ .Values.hub.server.csrf.authKey }}
        secure: {{ .Values.hub.server.csrf.secure }}
      oauth:
        {{- if .Values.hub.server.oauth.github.enabled }}
        github:
          clientID: {{ .Values.hub.server.oauth.github.clientID }}
          clientSecret: {{ .Values.hub.server.oauth.github.clientSecret }}
          redirectURL: {{ .Values.hub.server.oauth.github.redirectURL }}
          scopes: {{ .Values.hub.server.oauth.github.scopes }}
        {{- end }}
        {{- if .Values.hub.server.oauth.google.enabled }}
        google:
          clientID: {{ .Values.hub.server.oauth.google.clientID }}
          clientSecret: {{ .Values.hub.server.oauth.google.clientSecret }}
          redirectURL: {{ .Values.hub.server.oauth.google.redirectURL }}
          scopes: {{ .Values.hub.server.oauth.google.scopes }}
        {{- end }}
        {{- if .Values.hub.server.oauth.oidc.enabled }}
        oidc:
          clientID: {{ .Values.hub.server.oauth.oidc.clientID }}
          issuerURL: {{ .Values.hub.server.oauth.oidc.issuerURL }}
          clientSecret: {{ .Values.hub.server.oauth.oidc.clientSecret }}
          redirectURL: {{ .Values.hub.server.oauth.oidc.redirectURL }}
          scopes: {{ .Values.hub.server.oauth.oidc.scopes }}
          skipEmailVerifiedCheck: {{ .Values.hub.server.oauth.oidc.skipEmailVerifiedCheck }}
        {{- end }}
      xffIndex: {{ .Values.hub.server.xffIndex }}
    analytics:
      gaTrackingID: {{ .Values.hub.analytics.gaTrackingID }}
    theme:
      colors:
        primary: {{ .Values.hub.theme.colors.primary | quote }}
        secondary: {{ .Values.hub.theme.colors.secondary | quote }}
      images:
        appleTouchIcon192: {{ .Values.hub.theme.images.appleTouchIcon192 | quote }}
        appleTouchIcon512: {{ .Values.hub.theme.images.appleTouchIcon512 | quote }}
        openGraphImage: {{ .Values.hub.theme.images.openGraphImage | quote }}
        shortcutIcon: {{ .Values.hub.theme.images.shortcutIcon | quote }}
        websiteLogo: {{ .Values.hub.theme.images.websiteLogo | quote }}
      reportURL: {{ .Values.hub.theme.reportURL | quote }}
      sampleQueries:
        {{- range .Values.hub.theme.sampleQueries }}
        - name: {{ .name }}
          queryString: {{ .queryString | quote }}
        {{- end }}
      siteName: {{ .Values.hub.theme.siteName | quote }}
