---
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ include "eck-operator.fullname" . }}
  namespace: {{ .Release.Namespace }}
  labels:
    {{- include "eck-operator.labels" . | nindent 4 }}
data:
  eck.yaml: |-
    {{- $metricsPort := int (include "eck-operator.metrics.port" .)}}
    log-verbosity: {{ int .Values.config.logVerbosity }}
    {{- if and .Values.config.metrics.secureMode.enabled (eq $metricsPort 0) }}
    {{- fail "config.metrics.port must be greater than 0 when config.metrics.secureMode.enabled is true" }}
    {{- end }}
    metrics-port: {{ $metricsPort }}
    metrics-secure: {{ .Values.config.metrics.secureMode.enabled }}
    container-registry: {{ .Values.config.containerRegistry }}
    {{- with .Values.config.containerSuffix }}
    container-suffix: {{ . }}
    {{- end }}
    {{- with .Values.config.containerRepository }}
    container-repository: {{ . }}
    {{- end }}
    max-concurrent-reconciles: {{ int .Values.config.maxConcurrentReconciles }}
    {{- with .Values.config.passwordHashCacheSize }}
    password-hash-cache-size: {{ int . }}
    {{- end }}
    ca-cert-validity: {{ .Values.config.caValidity }}
    ca-cert-rotate-before: {{ .Values.config.caRotateBefore }}
    {{- with .Values.config.caDir }}
    ca-dir: {{ . }}
    {{- end }}
    cert-validity: {{ .Values.config.certificatesValidity }}
    cert-rotate-before: {{ .Values.config.certificatesRotateBefore }}
    disable-config-watch: {{ .Values.config.disableConfigWatch }}
    {{- with .Values.config.exposedNodeLabels }}
    exposed-node-labels: [{{ join "," .  }}]
    {{- end }}
    {{- with .Values.config.ipFamily }}
    ip-family: {{ . }}
    {{- end }}
    set-default-security-context: {{ .Values.config.setDefaultSecurityContext }}
    kube-client-timeout: {{ .Values.config.kubeClientTimeout }}
    {{- with .Values.config.kubeClientQPS }}
    kube-client-qps: {{ int . }}
    {{- end }}
    elasticsearch-client-timeout: {{ .Values.config.elasticsearchClientTimeout }}
    disable-telemetry: {{ .Values.telemetry.disabled }}
    distribution-channel: {{ .Values.telemetry.distributionChannel }}
    {{- with .Values.telemetry.interval }}
    telemetry-interval: {{ . }}
    {{- end }}
    validate-storage-class: {{ .Values.config.validateStorageClass }}
    {{- if .Values.tracing.enabled }}
    enable-tracing: true
    {{- end }}
    {{- if .Values.refs.enforceRBAC }}
    enforce-rbac-on-refs: true
    {{- end }}
    enable-webhook: {{ .Values.webhook.enabled }}
    {{- if .Values.webhook.enabled }}
    webhook-name: {{ include "eck-operator.webhookName" . }}
      {{- if not .Values.webhook.manageCerts }}
    manage-webhook-certs: false
    webhook-cert-dir: {{ .Values.webhook.certsDir }}
      {{- end }}
    webhook-port: {{ .Values.webhook.port }}
    {{- end }}
    {{- with .Values.managedNamespaces }}
    namespaces: [{{ join "," . }}]
    {{- end }}
    operator-namespace: {{ .Release.Namespace }}
    enable-leader-election: {{ .Values.config.enableLeaderElection }}
    elasticsearch-observation-interval: {{ .Values.config.elasticsearchObservationInterval }}
    {{- if not .Values.config.containerSuffix }}
    ubi-only: {{ .Values.config.ubiOnly }}
    {{- end }}
    {{- with .Values.webhook.certsSecret }}
    webhook-secret: {{ . }}
    {{- end }}
