kind: ConfigMap
apiVersion: v1
metadata:
  name: "{{ template "worker.fullname" . }}"
  labels:
    app: "{{ template "fullname" . }}"
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    release: "{{ .Release.Name }}"
    heritage: "{{ .Release.Service }}"
    component: worker
data:
  config.yaml: |
    # Anchore Service Configuration File

    service_dir: {{ .Values.globalConfig.configDir }}
    tmp_dir: {{ default "/tmp" .Values.workerConfig.analyzerScratchDir }}

    allow_awsecr_iam_auto: {{ .Values.globalConfig.allowECRUseIAMRole }}
    cleanup_images: {{ .Values.globalConfig.cleanupImages }}

    log_level: {{ .Values.workerConfig.logLevel }}
    host_id: ${ANCHORE_POD_NAME}
    internal_ssl_verify: {{ .Values.globalConfig.internalServicesSslVerifyCerts }}
    metrics:
      enabled: {{ .Values.globalConfig.enableMetrics }}
    credentials:
      users:
         admin:
           password: ${ANCHORE_ADMIN_PASSWORD}
           email: 'admin@myemail.com'
           external_service_auths:
           #  anchoreio:
           #    anchorecli:
           #      auth: 'myanchoreiouser:myanchoreiopass'
           #auto_policy_sync: true

      database:
        {{ if .Values.postgresql.enabled }}
        db_connect: 'postgresql+pg8000://${ANCHORE_DB_USER}:${ANCHORE_DB_PASSWORD}@{{ template "postgres.fullname" . }}:5432/{{ .Values.postgresql.postgresDatabase }}'
        {{ else }}
        db_connect: 'postgresql+pg8000://${ANCHORE_DB_USER}:${ANCHORE_DB_PASSWORD}@{{ .Values.postgresql.externalEndpoint}}/{{ .Values.postgresql.postgresDatabase }}'
        {{ end }}
        db_connect_args:
          timeout: 120
          ssl: {{ .Values.globalConfig.dbConfig.ssl }}
        db_pool_size: {{ .Values.globalConfig.dbConfig.connectionPoolSize }}
        db_pool_max_overflow: {{ .Values.globalConfig.dbConfig.connectionPoolSize }}
    services:
      analyzer:
        enabled: true
        endpoint_hostname: ${ANCHORE_POD_IP}
        listen: '0.0.0.0'
        port: {{ .Values.workerConfig.port }}
        cycle_timer_seconds: {{ .Values.workerConfig.cycleTimerSeconds }}
        max_threads: {{ .Values.workerConfig.concurrentTasksPerWorker }}
        analyzer_driver: nodocker
        ssl_cert: {{ .Values.workerConfig.ssl.certDir -}}/{{- .Values.workerConfig.ssl.certSecretCertName }}
        ssl_key: {{ .Values.workerConfig.ssl.certDir -}}/{{ .Values.workerConfig.ssl.certSecretKeyName }}
        ssl_enable: {{ .Values.globalConfig.internalServicesSslEnabled }}
