apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: dataservice-central-svc
spec:
  generators:
    - list:
        elements:
          # AWS
          - env: dev
            cluster: dev-base-us-west-2
            namespace: nightly-ms
          - env: stg
            cluster: staging-base-us-west-2
            namespace: staging-ms
          - env: prod
            cluster: prod-base-us-west-2
            namespace: prod-ms

  template:
    metadata:
      name: "{{env}}-dataservice-central-svc"
      annotations:
        notifications.argoproj.io/subscribe.on-deployed.dataservice-central-svc: ""
    spec:
      project: default # Use default project as a start
      source:
        repoURL: https://github.com/tidbcloud/app-delivery.git
        targetRevision: HEAD
        path: "dataservice-central-svc/envs/{{env}}"
      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: 10s
