apiVersion: v1
kind: Secret
metadata:
  name: {{ include "harbor.core" . }}-envvars
  labels: {{- include "common.labels.standard" . | nindent 4 }}
    {{- if .Values.commonLabels }}
    {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
    {{- end }}
    app.kubernetes.io/component: core
  {{- if .Values.commonAnnotations }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
type: Opaque
data:
  _REDIS_URL: {{ include "harbor.redisForCore" . | b64enc | quote }}
  _REDIS_URL_REG: {{ include "harbor.redisForGC" . | b64enc | quote }}
  REGISTRY_CREDENTIAL_USERNAME: {{ .Values.registry.credentials.username | b64enc | quote }}
  REGISTRY_CREDENTIAL_PASSWORD: {{ .Values.registry.credentials.password | b64enc | quote }}
  {{- if .Values.core.csrfKey }}
  CSRF_KEY: {{ .Values.core.csrfKey | b64enc | quote }}
  {{- else }}
  CSRF_KEY: {{ randAlphaNum 32 | b64enc | quote }}
  {{- end }}
  {{- if .Values.harborAdminPassword }}
  HARBOR_ADMIN_PASSWORD: {{ .Values.harborAdminPassword | b64enc | quote }}
  {{- else if (not .Values.forcePassword) }}
  HARBOR_ADMIN_PASSWORD: {{ randAlphaNum 10 | b64enc | quote }}
  {{ else }}
  HARBOR_ADMIN_PASSWORD: {{ required "A Harbor Admin Password is required!" .Values.harborAdminPassword }}
  {{- end }}
  POSTGRESQL_PASSWORD: {{ template "harbor.database.encryptedPassword" . }}
  {{- if .Values.clair.enabled }}
  CLAIR_DB_PASSWORD: {{ template "harbor.database.encryptedClairPassword" . }}
  {{- end }}
