apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: appset
  namespace: argocd
  annotations:
    argocd.argoproj.io/sync-wave: "1"
spec:
  goTemplate: true
  goTemplateOptions: ["missingkey=error"]
  generators:
    - git:
        repoURL: git@gitea.invuneon.ru:gitea_admin/infra.git
        revision: HEAD
        files:
          - path: charts/*/values/*.yaml
  template:
    metadata:
      name: '{{ trimSuffix ".yaml" .path.filename }}-{{ index .path.segments 1 }}'
      annotations:
        argocd.argoproj.io/manifest-generate-paths: ".;.."
      finalizers:
        - resources-finalizer.argocd.argoproj.io
    spec:
      project: default
      ignoreDifferences:
        - group: networking.k8s.io
          kind: Ingress
      source:
        repoURL: git@gitea.invuneon.ru:gitea_admin/infra.git
        targetRevision: HEAD
        path: charts/{{ index .path.segments 1 }}
        helm:
          releaseName: '{{ index .path.segments 1 }}'
          valueFiles:
            - secrets+age-import:///helm-secrets-private-keys/key.txt?values/{{ .path.filename }}
      destination:
        name: in-cluster
        namespace: '{{ trimSuffix ".yaml" .path.filename }}-{{ index .path.segments 1 }}'
      syncPolicy:
        automated:
          prune: true
          selfHeal: true
        syncOptions:
          - CreateNamespace=true
