{{- if .Values.enabled }}
{{- $namespace := .Release.Namespace -}}
{{- $scope := $ -}}
{{- range .Values.application.manifest }}
{{- if .enabled -}}
{{- $applicationName := .name | trunc 63 }}
---
apiVersion: v1
kind: Service
metadata:
  name: {{ $applicationName }}
  namespace: {{ $namespace }}
  labels:
    cmii.type: {{ $.Values.application.type }}
    cmii.app: {{ $applicationName }}
    helm.sh/chart: {{ include "frontend-app.chart" $scope }}
    app.kubernetes.io/managed-by: {{ $.Release.Service }}
    {{- if $.Values.global.image.tag }}
    app.kubernetes.io/version: {{ $.Values.global.image.tag }}
    {{- end }}
spec:
  type: {{ $.Values.global.appServiceType.frontend }}
  selector:
    cmii.type: {{ $.Values.application.type }}
    cmii.app: {{ $applicationName }}
  ports:
    - name: web-svc-port
      port: 9528
      protocol: TCP
      targetPort: 9528
---
{{- end }}
{{- end }}
{{- end }}
