{{- 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:
    {{- include "jenkins.labels" . | nindent 4 }}
    {{- range $key, $val := .Values.controller.prometheus.alertingRulesAdditionalLabels }}
    {{ $key }}: {{ $val | quote }}
    {{- end}}
spec:
  groups:
{{ toYaml .Values.controller.prometheus.alertingrules | indent 2 }}
{{- end }}
