{{ if .Values.x509_exporter.enabled }}
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: x509-exporter
  namespace: argocd
  annotations:
    argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
  finalizers:
  - resources-finalizer.argocd.argoproj.io
spec:
  destination:
    namespace: x509-exporter
    server: 'https://kubernetes.default.svc'
  sources:
  - repoURL: {{ .Values.cluster_config.manifests }}
    path: {{ .Values.cluster_config.policies }}/x509-exporter
    targetRevision: HEAD
  - repoURL: 'https://charts.enix.io'
    targetRevision: {{ .Values.x509_exporter.version }}
    chart: x509-certificate-exporter
    helm:
      values: |
        secretsExporter:
          excludeNamespaces:
            - sealed-secrets
          excludeLabels:
            - cert-manager.io/*
          resources:
            limits:
              memory: 100Mi
            requests:
              cpu: 20m
              memory: 100Mi
        prometheusServiceMonitor:
          extraLabels:
            k8s-app: x509-exporter
        prometheusRules:
          create: false
  project: sys
  syncPolicy:
    managedNamespaceMetadata:
      labels:
        component: sys
    syncOptions:
      - CreateNamespace=true
      - ApplyOutOfSyncOnly=true
    {{- if .Values.x509_exporter.autosync }}
    automated:
      prune: true
      # selfHeal: false
    {{- end }}
{{ end }}
