{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}

{{- if .Values.freeleaps.prometheusRule.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  name: {{ .Values.freeleaps.prometheusRule.name }}
  namespace: {{ .Values.freeleaps.prometheusRule.namespace | quote }}
  {{- with .Values.freeleaps.prometheusRule.labels }}
  labels:
    {{- toYaml . | nindent 4 }}
  {{- end }}
spec:
  groups:
  {{- with .Values.freeleaps.prometheusRule.rules }}
    - name: {{ $.Values.freeleaps.prometheusRule.name }}
      rules:
      {{- range . }}
        - alert: {{ .alert }}
          expr: {{ .expr | quote }}
          {{- if .for }}
          for: {{ .for }}
          {{- end }}
          {{- if .labels }}
          labels:
            {{- toYaml .labels | nindent 12 }}
          {{- end }}
          {{- if .annotations }}
          annotations:
            {{- toYaml .annotations | nindent 12 }}
          {{- end }}
      {{- end }}
  {{- end }}
{{- end }}
