{{- if and (.Values.rolloutAnalysisTemplates.enabled) (.Values.rolloutAnalysisTemplates.templates) -}}
{{- range $analysisMetrics := .Values.rolloutAnalysisTemplates.templates }}
apiVersion: argoproj.io/v1alpha1
kind: AnalysisTemplate
metadata:
  name: {{ .name }}
spec:
  args:
{{- if $.Values.rolloutAnalysisTemplates.authToken }}
  - name: prom-auth-token
    valueFrom:
      secretKeyRef:
        name: {{ include "promAuthSecretName" $  | trunc 63 }}
        key: authToken
{{- end }}
  - name: service-name
  metrics:
  - name: {{ $analysisMetrics.name }} 
{{ omit $analysisMetrics "name" | toYaml | indent 4 }}
---
{{- end }}
{{- end }}
