{{ $namespace := .Release.Namespace }}
{{ $appVersion := .Chart.AppVersion | quote }}
{{ $releaseCertificate := .Release.Service }}
{{ $releaseName := .Release.Name }}
{{- range $ingress := .Values.centralStorage.ingresses }}
{{- if not $ingress.tls.exists  }}
---
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: {{ $ingress.name }}
  namespace: {{ $namespace }}
  labels:
    app.kubernetes.io/version: {{ $appVersion }}
    app.kubernetes.io/name: {{ $ingress.name | quote }}
    app.kubernetes.io/managed-by: {{ $releaseCertificate }}
    app.kubernetes.io/instance: {{ $releaseName }}
spec:
  commonName: {{ $ingress.host }}
  dnsNames:
    - {{ $ingress.host }}
  issuerRef:
    name: {{ $ingress.tls.issuerRef.name }}
    kind: {{ $ingress.tls.issuerRef.kind }}
  secretName: {{ $ingress.tls.name }}
{{- end }}
{{- end }}