{{- if and .Values.controller.metrics.enabled .Values.controller.metrics.rules.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  name: {{ include "argocd.application-controller" . }}
  {{- if .Values.controller.metrics.rules.namespace }}
  namespace: {{ .Values.controller.metrics.rules.namespace }}
  {{- end }}
  labels:
    {{- include "common.labels.standard" . | nindent 4 }}
    {{- if .Values.commonLabels }}
    {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
    {{- end }}
    {{- if .Values.controller.metrics.rules.selector }}
    {{- include "common.tplvalues.render" ( dict "value" .Values.controller.metrics.rules.selector "context" $ ) | nindent 4 }}
    {{- end }}
    {{- if .Values.controller.metrics.rules.additionalLabels }}
    {{- include "common.tplvalues.render" ( dict "value" .Values.controller.metrics.rules.additionalLabels "context" $ ) | nindent 4 }}
    {{- end }}
spec:
  groups:
  - name: argocd
    rules:
    {{- include "common.tplvalues.render" ( dict "value" .Values.controller.metrics.rules.spec "context" $ ) | nindent 6 }}
{{- end }}
