{{- if .Values.enabled }}
  {{- $namespace := .Release.Namespace -}}
  {{- $TenantEnvironment := .Values.global.domain.TenantEnvironment -}}
  {{- $DeployDomainName := .Values.global.domain.DeployDomainName -}}
  {{- $IsPrivateDeployment := .Values.global.domain.IsPrivateDeployment -}}
  {{- range $applicationName, $values := .Values.frontendApplication.manifest }}
---
kind: ConfigMap
apiVersion: v1
metadata:
  {{- if eq $values.shortname "" }}
  name: tenant-prefix-platform
  {{- else }}
  name: tenant-prefix-{{ $values.shortname }}
  {{- end }}
  namespace: {{ $namespace }}
data:
  ingress-config.js: |-
    // 从ConfigMap中注入
    // injected from ConfigMap
    var __GlobalIngressConfig = {
    {{- if $IsPrivateDeployment }}
      TenantEnvironment: "",
    {{- else }}
      TenantEnvironment: {{ $TenantEnvironment | quote -}},
    {{- end }}
      CloudHOST: {{ $DeployDomainName | quote -}},
    {{- if not (contains "appli" $values.shortname ) }}
    {{- /* short name not contains application, judge for situations */}}
    {{- if contains "cms-portal" $values.shortname }}
        ApplicationShortName: "cmsportal",
    {{- else if contains "-rescue" $values.shortname }}
        ApplicationShortName: {{ trimSuffix "-rescue" $values.shortname | quote -}},
    {{- else if contains "screen" $values.shortname }}
        ApplicationShortName: {{ trimSuffix "-screen" $values.shortname | quote -}},
    {{- else }}
      ApplicationShortName: {{ $values.shortname | quote }},
    {{- end }}
    {{- else }}
      ApplicationShortName: {{ trimSuffix "-application" $values.shortname | quote -}},
    {{- end }}
    {{- range $appShortNamePlusTenantEnv, $appClientId := $values}}
    {{- $realApplicationNamePlusTenantEnv := cat $values.shortname $TenantEnvironment | replace " " "-" }}
    {{- if hasPrefix $appShortNamePlusTenantEnv $realApplicationNamePlusTenantEnv }}
      AppClientId: {{ $appClientId | quote }}
    {{- end }}
    {{- end }}
    }
---
{{- end }}
  {{- end }}