{{- if (not .Values.config.existingConfig) }}
apiVersion: v1
kind: ConfigMap
metadata:
  labels: {{ include "kyverno.labels" . | nindent 4 }}
    app: kyverno
  name: {{ template "kyverno.configMapName" . }}
  namespace: {{ template "kyverno.namespace" . }}
data:
  # resource types to be skipped by kyverno policy engine
  {{- if .Values.config.resourceFilters }}
  resourceFilters: {{ tpl (join "" .Values.config.resourceFilters) . | quote }}
  {{- end -}}
  {{- if .Values.config.excludeGroupRole }}
  excludeGroupRole: {{ join "," .Values.config.excludeGroupRole | quote }}
  {{- end -}}
  {{- if .Values.config.excludeUsername }}
  excludeUsername: {{ join "," .Values.config.excludeUsername | quote }}
  {{- end -}}
  {{- if .Values.config.webhooks }}
  webhooks: {{ .Values.config.webhooks  | toJson | quote }}
  {{- end -}}
  {{- if .Values.config.generateSuccessEvents }}
  generateSuccessEvents: {{ .Values.config.generateSuccessEvents | quote }}
  {{- end -}}
{{- end -}}
