apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: external-secrets
spec:
  goTemplate: true
  generators:
    # targets all clusters
    - clusters:
        selector:
          matchExpressions:
            - key: clusterType
              operator: Exists
  template:
    metadata:
      name: "external-secrets-{{ .name }}"
    spec:
      destination:
        namespace: external-secrets
        server: "{{ .server }}"
      project: default
      sources:
        - chart: external-secrets
          repoURL: "https://charts.external-secrets.io"
          targetRevision: 0.14.4
          helm:
            releaseName: external-secrets
            parameters:
              - name: installCRDs
                value: "true"
              - name: serviceAccount.name
                value: external-secrets
            valueFiles:
              - $values/kubernetes/{{ .name }}/helm/external-secrets.yaml
        - repoURL: "https://github.com/kubernetes/k8s.io.git"
          targetRevision: main
          ref: values
      syncPolicy:
        automated:
          prune: true
          selfHeal: true
        syncOptions:
          - CreateNamespace=true
