{{- if and (index .Values "argo-cd" "kubezero" "bootstrap") (index .Values "argo-cd" "kubezero" "repoUrl") }}
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: kubezero-git-sync
  namespace: argocd
  labels:
    {{- include "kubezero-lib.labels" . | nindent 4 }}
  annotations:
    argocd.argoproj.io/sync-wave: "-20"
spec:
  destination:
    namespace: argocd
    server: https://kubernetes.default.svc
  project: kubezero
  source:
    {{- with index .Values "argo-cd" "kubezero" }}
    repoURL: {{ .repoUrl }}
    targetRevision: {{ .targetRevision }}
    path: {{ .path }}
    {{- end }}
    directory:
      recurse: true
  syncPolicy:
    automated:
      prune: true
    syncOptions:
      - ServerSideApply=true
      - ApplyOutOfSyncOnly=true
{{- end }}