apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: serverless-global-service
spec:
  generators:
    - list:
        elements:
          - env: dev
            cluster: dev-base-us-west-2
            notification_disabled: "true"
          - env: staging
            cluster: staging-base-us-west-2
            notification_disabled: "true"
          - env: prod
            cluster: prod-base-us-west-2
  template:
    metadata:
      name: "{{env}}-serverless-global-service"
      annotations:
        notifications.argoproj.io/subscribe.on-deployed.tidb-management-service: ""
        notifications.argocd.tidbcloud/subscribe.on-deployed.disabled: "{{notification_disabled}}"
    spec:
      project: default # Use default project as a start
      source:
        repoURL: https://github.com/tidbcloud/app-delivery.git
        targetRevision: HEAD
        path: "serverless-global-service/envs/{{env}}"
      destination:
        name: "{{cluster}}"
        namespace: tidb-management-service
      syncPolicy:
        automated:
          selfHeal: true
          prune: true
        syncOptions:
          - CreateNamespace=true
          - PruneLast=true
        retry:
          limit: 5
          backoff:
            duration: 5s
            factor: 2
            maxDuration: 3m
