{{- define "logging-values" }}
{{- if or .Values.logging.es .Values.logging.kibana }}
eck-operator:
  enabled: true
  {{- with index .Values "logging" "eck-operator" }}
  {{- toYaml . | nindent 2 }}
  {{- end }}
{{- end }}

{{- if .Values.logging.elastic_password }}
elastic_password: {{ .Values.logging.elastic_password }}
{{- end }}

{{- if .Values.logging.version }}
version: {{ .Values.logging.version }}
{{- end }}

{{- if .Values.logging.fullnameOverride }}
fullnameOverride: {{ .Values.logging.fullnameOverride }}
{{- end }}

{{- if .Values.logging.es }}
es:
  {{- if .Values.logging.es.nodeSets }}
  nodeSets:
  {{- with .Values.logging.es.nodeSets }}
  {{- toYaml . | nindent 2 }}
  {{- end }}
  {{- end }}
  prometheus: {{ .Values.metrics.enabled }}

  {{- if .Values.logging.es.s3Snapshot }}
  s3Snapshot:
    {{- with .Values.logging.es.s3Snapshot }}
    {{- toYaml . | nindent 4 }}
    {{- end }}
  {{- end }}
{{- end }}

{{- if .Values.logging.kibana }}
kibana:
  {{- with .Values.logging.kibana }}
  {{- toYaml . | nindent 2 }}
  {{- end }}
{{- end }}

{{- with .Values.logging.fluentd }}
fluentd:
  enabled: {{ .enabled }}
  replicaCount: {{ default 1 .replicaCount }}
  metrics:
    serviceMonitor:
      enabled: {{ $.Values.metrics.enabled }}
  url: {{ .url }}
  {{- if .output }}
  output:
    host: {{ .output.host }}
  {{- end }}
  {{- with .affinity }}
  affinity:
    {{- toYaml . | nindent 4 }}
  {{- end }}
  {{- if .extraEnvVars }}
  extraEnvVars:
    {{- toYaml .extraEnvVars | nindent 8 }}
  {{- end }}
  {{- if and .istio $.Values.istio.enabled }}
  istio:
    {{- with .istio }}
    {{- toYaml . | nindent 4 }}
    {{- end }}
  {{- end }}
{{- end }}

{{- if index .Values "logging" "fluent-bit" }}
fluent-bit:
  enabled: {{ index .Values.logging "fluent-bit" "enabled" }}
  serviceMonitor:
    enabled: {{ .Values.metrics.enabled }}
  {{- if index .Values.logging "fluent-bit" "config" }}
  config:
    {{- with index .Values.logging "fluent-bit" "config" }}
    {{- toYaml . | nindent 4 }}
    {{- end }}
  {{- end }}
{{- end }}

{{- end }}


{{- define "logging-argo" }}

  ignoreDifferences:
  - group: admissionregistration.k8s.io
    kind: ValidatingWebhookConfiguration
    jsonPointers:
    - /webhooks/0/clientConfig/caBundle
    - /webhooks/1/clientConfig/caBundle
    - /webhooks/2/clientConfig/caBundle
    - /webhooks/3/clientConfig/caBundle
    - /webhooks/4/clientConfig/caBundle
    - /webhooks/5/clientConfig/caBundle
    - /webhooks/6/clientConfig/caBundle
    - /webhooks/7/clientConfig/caBundle
    - /webhooks/8/clientConfig/caBundle
    - /webhooks/9/clientConfig/caBundle
  - group: apiextensions.k8s.io
    kind: CustomResourceDefinition
    jsonPointers:
    - /status
{{- end }}

{{ include "kubezero-app.app" . }}
