{{- if .Values.kubezero.enabled }}
apiVersion: argoproj.io/v1alpha1
kind: AppProject
metadata:
  name: kubezero
  namespace: argocd
  labels:
{{ include "kubezero-lib.labels" . | indent 4 }}
spec:
  description: KubeZero - ZeroDownTime Kubernetes Platform

  # Allow manifests to deploy from any Git repos
  sourceRepos:
  - '*'

  destinations:
  - namespace: argocd
    server: https://kubernetes.default.svc
  - namespace: kube-system
    server: https://kubernetes.default.svc
  - namespace: cert-manager
    server: https://kubernetes.default.svc
  - namespace: istio-system
    server: https://kubernetes.default.svc
  - namespace: istio-ingress
    server: https://kubernetes.default.svc
  - namespace: monitoring
    server: https://kubernetes.default.svc
  - namespace: elastic-system
    server: https://kubernetes.default.svc
  - namespace: logging
    server: https://kubernetes.default.svc

  clusterResourceWhitelist:
  - group: '*'
    kind: '*'

---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: kubezero
  namespace: argocd
  labels:
{{ include "kubezero-lib.labels" . | indent 4 }}
spec:
  project: kubezero
  source:
    repoURL: {{ .Values.kubezero.repoURL }}
    targetRevision: {{ .Values.kubezero.targetRevision }}
    path: {{ .Values.kubezero.path }}

    helm:
      valueFiles:
      {{- toYaml .Values.kubezero.valuesFiles | nindent 6 }}

  destination:
    server: {{ .Values.kubezero.server }}
    namespace: argocd

  {{- with .Values.kubezero.syncPolicy }}
  syncPolicy:
    {{- toYaml . | nindent 4 }}
  {{- end }}
{{- end }}
