{{- if and .Values.global.secret.create .Values.secret.create -}}
apiVersion: v1
kind: Secret
metadata:
  name: {{ template "chart.fullname" . }}-admin
  labels:
    app.kubernetes.io/component: web-admin
    {{- include "chart.labels" . | nindent 4 }}
type: Opaque
data:
  TIMEBASE_URL: {{ printf "dxtick://%s:%s" .Values.server.host .Values.server.port | b64enc | quote }}

  {{- if or .Values.server.user .Values.server.password }}
  TIMEBASE_USER: {{ .Values.server.user | b64enc | quote }}
  TIMEBASE_PASSWORD: {{ .Values.server.password | b64enc | quote }}
  {{- end }}
  {{- range $key, $value := .Values.secret.records }}
  {{ $key }}: {{ $value | b64enc | quote }}
  {{- end }}
{{- end -}}