{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}

{{- if not .Values.hub.existingSecret }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "jupyterhub.hub.name" . }}
  namespace: {{ .Release.Namespace | quote }}
  labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
    app.kubernetes.io/component: hub
  {{- if .Values.commonAnnotations }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
type: Opaque
data:
  values.yaml: {{ include "common.tplvalues.render" ( dict "value" .Values.hub.configuration "context" $ ) | b64enc | quote }}
  proxy-token: {{ default (randAlphaNum 32) .Values.proxy.secretToken | b64enc | quote }}
  hub.config.JupyterHub.cookie_secret: {{ include "jupyterhub.hub.config.JupyterHub.cookie_secret" . | b64enc | quote }}
  hub.config.CryptKeeper.keys: {{ include "jupyterhub.hub.config.CryptKeeper.keys" . | b64enc | quote }}
  {{- range $key, $service := .Values.hub.services }}
  hub.services.{{ $key }}.apiToken: {{ include "jupyterhub.hub.services.get_api_token" (dict "serviceKey" $key "context" $) | b64enc | quote }}
  {{- end }}
{{- end }}
