apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: clinic-gateway
spec:
  generators:
    - list:
        elements:
          - env: prod-cloud
            cluster: prod-clinic-cloud
            namespace: kong-prod-cloud
            relaseName: clinic-gateway-prod-cloud
          - env: prod-op
            cluster: prod-clinic-op
            namespace: kong-prod-op
            relaseName: clinic-gateway-prod-op
  template:
    metadata:
      name: "{{env}}-clinic-gateway"
    spec:
      project: default # Use default project as a start
      sources:
        - repoURL: https://charts.konghq.com
          chart: kong
          targetRevision: 2.11.0
          helm:
            releaseName: "{{relaseName}}"
            valueFiles:
              - $values/clinic/clinic-kong/values/envs/{{env}}/values.yaml
        - repoURL: https://github.com/tidbcloud/app-delivery.git
          targetRevision: HEAD
          ref: values
      destination:
        name: "{{cluster}}"
        namespace: "{{namespace}}"
      syncPolicy:
        automated:
          selfHeal: true
          prune: true
        syncOptions:
          - CreateNamespace=true
          - PruneLast=true
        retry:
          limit: 5
          backoff:
            duration: 5s
            factor: 2
            maxDuration: 3m
