{{ if .Values.jaeger_operator.enabled }}
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: jaeger-operator
  namespace: argocd
  finalizers:
  - resources-finalizer.argocd.argoproj.io
spec:
  destination:
    namespace: observability
    server: 'https://kubernetes.default.svc'
  sources:
  - repoURL: {{ .Values.cluster_config.manifests }}
    path: {{ .Values.cluster_config.policies }}/jaeger-operator
    targetRevision: HEAD
  - repoURL: "https://github.com/jaegertracing/jaeger-operator"
    targetRevision: v{{ .Values.jaeger_operator.version }}
    path: bundle/manifests
    directory:
      # Exclude jaeger-operator clusterserviceversion, as we don't have operator lifecycle manager installed
      exclude: jaeger-operator.clusterserviceversion.yaml
  project: sys
  syncPolicy:
    managedNamespaceMetadata:
      labels:
        component: sys
    syncOptions:
      - CreateNamespace=true
      - ApplyOutOfSyncOnly=true
    {{- if .Values.jaeger_operator.autosync }}
    automated:
      prune: true
      # selfHeal: false
    {{- end }}
{{ end }}
