apiVersion: v1
kind: Secret
metadata:
  name: {{ include "harbor.jobservice" . }}-config
  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: jobservice
  {{- if .Values.commonAnnotations }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
stringData:
  config.yml: |+
    #Server listening port
    protocol: {{ ternary "https" "http" .Values.internalTLS.enabled | quote }}
    port: {{ ternary .Values.jobservice.containerPorts.https .Values.jobservice.containerPorts.http .Values.internalTLS.enabled }}
    {{- if .Values.internalTLS.enabled }}
    https_config:
      cert: "/etc/harbor/ssl/jobservice/tls.crt"
      key: "/etc/harbor/ssl/jobservice/tls.key"
    {{- end }}
    worker_pool:
      workers: {{ .Values.jobservice.maxJobWorkers }}
      backend: "redis"
      redis_pool:
        redis_url: {{ include "harbor.redisForJobservice" . | quote }}
        namespace: {{ .Values.jobservice.redisNamespace | quote }}
    job_loggers:
      {{- if eq .Values.jobservice.jobLogger "file" }}
      - name: "FILE"
        level: {{ .Values.logLevel | upper }}
        settings: # Customized settings of logger
          base_dir: "/var/log/jobs"
        sweeper:
          duration: 14 #days
          settings: # Customized settings of sweeper
            work_dir: "/var/log/jobs"
      {{- else if eq .Values.jobservice.jobLogger "database" }}
      - name: "DB"
        level: {{ .Values.logLevel | upper }}
        sweeper:
          duration: 14 #days
      {{- else }}
      - name: "STD_OUTPUT"
        level: {{ .Values.logLevel | upper }}
      {{- end }}
    #Loggers for the job service
    loggers:
      - name: "STD_OUTPUT"
        level: {{ .Values.logLevel | upper }}
    metric:
      enabled: {{ .Values.metrics.enabled }}
      path: {{ .Values.metrics.path }}
      port: {{ .Values.jobservice.containerPorts.metrics }}
