{{ if .Values.api_router_schema_updater.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: api-router-schema-updater
spec:
  replicas: 1
  selector:
    matchLabels:
      app: api-router-schema-updater
  template:
    metadata:
      name: api-router-schema-updater
      labels:
        app: api-router-schema-updater
    spec:
      containers:
      - name: api-router-schema-updater
        image: docker.io/goalprofit/api-router-schema-updater:{{.Values.api_router_schema_updater.version}}
        imagePullPolicy: Always
        volumeMounts:
        - mountPath: /data
          name: customer
          subPath: data/api-router
        env:
        - name: APOLLO_ELV2_LICENSE
          value: accept
        command:
          {{ if .Values.de2.enabled }}
          - bash
          - /app/run.sh
          {{ if and .Values.server_api.enabled .Values.server_api.use_in_federation }}
          - >-
            server-api: { routing_url: http://server-api:8080/, schema: {
            subgraph_url: http://server-api:8080/ } }
          {{ end }}
          {{ if and .Values.orm.enabled .Values.orm.use_in_federation }}
          - >-
            domain-2.0: { routing_url: http://orm/api/v2, schema: {
            subgraph_url: http://orm/api/v1 } } 
          {{ end }}
          {{ if and .Values.camunda2.enabled .Values.camunda2.use_in_federation }}
          - >-
            camunda2: { routing_url: http://camunda-api:4002/, schema: {
            subgraph_url: http://camunda-api:4002/ } } 
          {{ end }}
          {{ else if .Values.fusion.enabled }}
          - bash
          - /app/run.sh
          - >-
            server-api: { routing_url: http://server-api:8080/, schema: {
            subgraph_url: http://server-api:8080/ } } 
          - >-
            server-orm: { routing_url: http://server:3000/, schema: {
            subgraph_url: http://server:3000/ } } 
          - >-
            camunda2: { routing_url: http://camunda-api:4002/, schema: {
            subgraph_url: http://camunda-api:4002/ } } 
          {{ else }}
          - bash
          - /app/run.sh
          {{ if .Values.server_api.enabled }}
          - "{{.Values.server_api.router_config }}"
          {{ end }}

          {{ if .Values.camunda2.enabled }}
          - "{{.Values.camunda2.router_config }}"
          {{ end }}
          {{ end }}
          

      imagePullSecrets:
      - name: regcred
        
      volumes:
      - name: customer
        {{ include "app.customer_volume" . | nindent 8}}
      {{ include "app.affinity" . | nindent 6}}

---
apiVersion: v1
kind: Service
metadata:
  name: api-router-schema-updater
spec:
  type: ClusterIP
  selector:
    app: api-router-schema-updater
  ports:
    - name: http
      protocol: TCP
      port: 8080
      targetPort: 8080
{{ end }}
