{{- if and .Values.controller.prometheus.enabled .Values.controller.prometheus.alertingrules }}
---
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  name: {{ template "jenkins.fullname" . }}
{{- if .Values.controller.prometheus.prometheusRuleNamespace }}
  namespace: {{ .Values.controller.prometheus.prometheusRuleNamespace }}
{{- else }}
  namespace: {{ template "jenkins.namespace" . }}
{{- end }}
  labels:
    "app.kubernetes.io/name": '{{ template "jenkins.name" .}}'
    {{- if .Values.renderHelmLabels }}
    "helm.sh/chart": "{{ template "jenkins.label" .}}"
    {{- end }}
    "app.kubernetes.io/managed-by": "{{ .Release.Service }}"
    "app.kubernetes.io/instance": "{{ .Release.Name }}"
    "app.kubernetes.io/component": "{{ .Values.controller.componentName }}"
    {{- range $key, $val := .Values.controller.prometheus.alertingRulesAdditionalLabels }}
    {{ $key }}: {{ $val | quote }}
    {{- end}}
spec:
  groups:
{{ toYaml .Values.controller.prometheus.alertingrules | indent 2 }}
{{- end }}
