apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: clinic-opensearch-dashboards
spec:
  generators:
    - list:
        elements:
          - env: prod-cloud
            cluster: prod-clinic-cloud
            namespace: clinic-prod-cloud
          - env: prod-op
            cluster: prod-clinic-op
            namespace: clinic-prod-op
  template:
    metadata:
      name: "{{env}}-clinic-opensearch-dashboards"
    spec:
      project: default # Use default project as a start
      sources:
        - repoURL: https://opensearch-project.github.io/helm-charts/
          chart: opensearch-dashboards
          targetRevision: 1.3.1
          helm:
            releaseName: opensearch-dashboards
            valueFiles:
              - $values/clinic/clinic-api/values/opensearch-dashboards/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
