apiVersion: v1
kind: ConfigMap
metadata:
  name: preset-mesh-config
data:
  preset-mesh-config.json: |
    {
      "sidecar": {
        "enablePrivilegedInitContainer": {{.Values.OpenServiceMesh.enablePrivilegedInitContainer}},
        "logLevel": "{{.Values.OpenServiceMesh.envoyLogLevel}}",
        "maxDataPlaneConnections": {{.Values.OpenServiceMesh.maxDataPlaneConnections}},
        "envoyImage": "{{.Values.OpenServiceMesh.sidecarImage}}",
        "envoyWindowsImage": "{{.Values.OpenServiceMesh.sidecarWindowsImage}}",
        "initContainerImage": "{{ .Values.OpenServiceMesh.image.registry }}/init:{{ .Values.OpenServiceMesh.image.tag }}",
        "configResyncInterval": "{{.Values.OpenServiceMesh.configResyncInterval}}"
      },
      "traffic": {
        "enableEgress": {{.Values.OpenServiceMesh.enableEgress}},
        "useHTTPSIngress": {{.Values.OpenServiceMesh.useHTTPSIngress}},
        "enablePermissiveTrafficPolicyMode": {{.Values.OpenServiceMesh.enablePermissiveTrafficPolicy}},
        "outboundPortExclusionList": {{.Values.OpenServiceMesh.outboundPortExclusionList}},
        "inboundPortExclusionList": {{.Values.OpenServiceMesh.inboundPortExclusionList}},
        "outboundIPRangeExclusionList": {{.Values.OpenServiceMesh.outboundIPRangeExclusionList}}
      },
      "observability": {
        "enableDebugServer": {{.Values.OpenServiceMesh.enableDebugServer}},
        "osmLogLevel": "{{.Values.OpenServiceMesh.controllerLogLevel}}",
        "tracing": {
          "enable": {{.Values.OpenServiceMesh.tracing.enable}}{{- if .Values.OpenServiceMesh.tracing.enable }},{{- end }}
          {{- if .Values.OpenServiceMesh.tracing.enable }}
          "port": {{.Values.OpenServiceMesh.tracing.port}},
          "address": {{include "osm.tracingAddress"}},
          "endpoint": {{.Values.OpenServiceMesh.tracing.endpoint  | quote}}
          {{- end }}
        }
      },
      "certificate": {
        "serviceCertValidityDuration": "{{.Values.OpenServiceMesh.certificateProvider.serviceCertValidityDuration}}",
        {{- if .Values.contour.enabled }}
        "ingressGateway": {
          "subjectAltNames": ["osm-contour-envoy.{{include "osm.namespace" .}}.cluster.local"],
          "validityDuration": "24h",
          "secret": {
            "name": "osm-contour-envoy-client-cert",
            "namespace": "{{include "osm.namespace" .}}"
          }
        },
        {{- end }}
        "certKeyBitSize": {{.Values.OpenServiceMesh.certificateProvider.certKeyBitSize}}
      },
      "featureFlags": {
        "enableWASMStats": {{.Values.OpenServiceMesh.featureFlags.enableWASMStats}},
        "enableEgressPolicy": {{.Values.OpenServiceMesh.featureFlags.enableEgressPolicy}},
        "enableMulticlusterMode": {{.Values.OpenServiceMesh.featureFlags.enableMulticlusterMode}},
        "enableSnapshotCacheMode": {{.Values.OpenServiceMesh.featureFlags.enableSnapshotCacheMode}},
        "enableAsyncProxyServiceMapping": {{.Values.OpenServiceMesh.featureFlags.enableAsyncProxyServiceMapping}},
        "enableValidatingWebhook": {{.Values.OpenServiceMesh.featureFlags.enableValidatingWebhook}},
        "enableIngressBackendPolicy": {{.Values.OpenServiceMesh.featureFlags.enableIngressBackendPolicy}},
        "enableEnvoyActiveHealthChecks": {{.Values.OpenServiceMesh.featureFlags.enableEnvoyActiveHealthChecks}},
        "enableRetryPolicy": {{.Values.OpenServiceMesh.featureFlags.enableRetryPolicy}}
      }
    }
