{{ if .Values.postgres_operator.enabled }}
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: postgres-operator
  namespace: argocd
spec:
  destination:
    namespace: cnpg
    server: 'https://kubernetes.default.svc'
  sources:
  - repoURL: {{ .Values.cluster_config.manifests }}
    path: {{ .Values.cluster_config.policies }}/cnpg
    targetRevision: HEAD
  - repoURL: 'https://cloudnative-pg.github.io/charts'
    targetRevision: {{ .Values.postgres_operator.version }}
    chart: cloudnative-pg
    helm:
      values: |
        additionalArgs: []
        config:
          data:
            INHERITED_ANNOTATIONS: "linkerd.io/*"
            INHERITED_LABELS: "velero.io/*"
  project: sys
  syncPolicy:
    managedNamespaceMetadata:
      labels:
        component: sys
    syncOptions:
      - CreateNamespace=true
      - ApplyOutOfSyncOnly=true
      - ServerSideApply=true
    {{- if .Values.postgres_operator.version }}
    automated:
      # selfHeal: false
      prune: true
    {{- end }}
{{ end }}
