{{- if .Values.metrics.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ include "harbor.exporter" . }}-envvars
  namespace: {{ .Release.Namespace | quote }}
  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: exporter
  {{- if .Values.commonAnnotations }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
data:
  LOG_LEVEL: {{ .Values.logLevel | quote }}
  HARBOR_EXPORTER_PORT: {{ .Values.exporter.containerPorts.metrics | quote }}
  HARBOR_EXPORTER_METRICS_PATH: {{ .Values.metrics.path | quote }}
  HARBOR_METRIC_NAMESPACE: harbor
  HARBOR_METRIC_SUBSYSTEM: exporter
  HARBOR_REDIS_URL: {{ include "harbor.redisForJobservice" . | quote }}
  HARBOR_REDIS_NAMESPACE: {{ .Values.jobservice.redisNamespace | quote }}
  HARBOR_SERVICE_SCHEME: {{ ternary "https" "http" .Values.internalTLS.enabled | quote }}
  HARBOR_SERVICE_HOST: {{ include "harbor.core" . | quote }}
  HARBOR_SERVICE_PORT: {{ ternary .Values.core.service.ports.https .Values.core.service.ports.http .Values.internalTLS.enabled | quote }}
  HARBOR_DATABASE_HOST: {{ include "harbor.database.host" . | quote }}
  HARBOR_DATABASE_PORT: {{ include "harbor.database.port" . | quote  }}
  HARBOR_DATABASE_USERNAME: {{ include "harbor.database.username" . | quote }}
  HARBOR_DATABASE_DBNAME: {{ include "harbor.database.coreDatabase" . | quote }}
  HARBOR_DATABASE_SSLMODE: {{ include "harbor.database.sslmode" . | quote }}
{{- end }}
