{{- if .Values.secrets.externalSecret.enabled }}
apiVersion: "external-secrets.io/v1beta1"
kind: ExternalSecret
metadata:
  name: {{ include "name" $ }}-external-secret
  namespace: {{ $.Release.Namespace }}
spec:
  refreshInterval: 1h
  secretStoreRef:
    name: {{ .Values.secrets.externalSecret.secretStoreName }}
    kind: SecretStore
  target:
    name: {{ .Values.secrets.externalSecret.secretName }}
  data:
    {{- range $key, $value := .Values.secrets.externalSecret.parameters }}
    - secretKey: {{ $key | quote }}
      remoteRef:
        key: {{ $value | quote }}
    {{- end }}
{{- end }}