apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: gateway-api-crds
spec:
  generators:
    - list:
        elements:
          - env: staging-us-west-2-lyc
            cluster: staging-seed-us-west-2-lyc
          - env: prod-eu-west-1
            cluster: prod-seed-eu-west-1
          - env: staging-us-west-2-mjp
            cluster: staging-seed-us-west-2-mjp
          - env: prod-us-west-2-lyc
            cluster: prod-seed-us-west-2-lyc
          - env: prod-asia-south1
            cluster: prod-seed-asia-south1
          - env: dev-southeastasia-chengfei
            cluster: dev-southeastasia-chengfei-controlplane
          - env: prod-ap-southeast-7
            cluster: prod-seed-ap-southeast-7
          - env: staging-japaneast
            cluster: staging-japaneast-controlplane
  template:
    metadata:
      name: "{{cluster}}-gateway-api-crds"
    spec:
      project: default # Use default project as a start
      source:
        repoURL: https://github.com/tidbcloud/app-delivery.git
        targetRevision: HEAD
        path: "dedicated-regional-server/gateway-api-crds/envs/{{env}}"
      destination:
        name: "{{cluster}}"
        namespace: kong
      syncPolicy:
        automated:
          selfHeal: true
          # prune: true  # auto prune CRD is dangerous, let's prune manually
        syncOptions:
          - CreateNamespace=true
        retry:
          limit: 5
          backoff:
            duration: 5s
            factor: 2
            maxDuration: 3m
