{{- if .Values.mariadb_operator.enabled }}
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: mariadb-operator
  namespace: argocd
  annotations:
    argocd.argoproj.io/sync-wave: "-1"
spec:
  destination:
    namespace: mariadb-operator
    server: 'https://kubernetes.default.svc'
  sources:
  - repoURL: {{ .Values.cluster_config.manifests }}
    path: {{ .Values.cluster_config.policies }}/mariadb-operator
    targetRevision: HEAD
  - repoURL: 'https://helm.mariadb.com/mariadb-operator'
    targetRevision: {{ .Values.mariadb_operator.version }}
    chart: mariadb-operator
    helm:
      values: |
        ha:
          enabled: false
        metrics:
          enabled: true
          serviceMonitor:
            additionalLabels:
              release: prometheus
            enabled: true
        webhook:
          certificate:
            certManager: false
          serviceMonitor:
            additionalLabels:
              release: prometehus
  project: sys
  syncPolicy:
    syncOptions:
    - CreateNamespace=true
    - ServerSideApply=true
    {{- if .Values.mariadb_operator.autosync }}
    automated:
      prune: true
      # selfHeal: false
    {{- end }}
{{- end }}
