{{- if .Values.scanner.enabled -}}
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "chart.resourceNamePrefix" . }}scanner-config
  labels:
    {{- include "chart.labels" . | nindent 4 }}
type: Opaque
stringData:
  scanner.yaml: |-
    restrictedHTTPClient: {{ .Values.restrictedHTTPClient }}
    log:
      level: {{ .Values.log.level }}
      pretty: {{ .Values.log.pretty }}
    db:
      host: {{ default (printf "%s-postgresql.%s" .Release.Name .Release.Namespace) .Values.db.host }}
      port: {{ .Values.db.port }}
      database: {{ .Values.db.database }}
      user: {{ .Values.db.user | quote }}
      password: {{ .Values.db.password | quote }}
    creds:
      dockerUsername: {{ .Values.creds.dockerUsername }}
      dockerPassword: {{ .Values.creds.dockerPassword }}
    events:
      scanningErrors: {{ .Values.events.scanningErrors }}
    scanner:
      concurrency: {{ .Values.scanner.concurrency }}
      trivyURL: {{ .Values.scanner.trivyURL | default (printf "http://%s%s:8081" (include "chart.resourceNamePrefix" .) "trivy") }}
{{- end }}
