kind: ExternalSecret
apiVersion: external-secrets.io/v1beta1
metadata:
  name: {{ $.Values.externalSecrets.externalSystemsExternalSecrets.name }}
spec:
  refreshInterval: {{ $.Values.externalSecrets.externalSystemsExternalSecrets.refreshInterval }}
  secretStoreRef:
    name: {{ $.Values.externalSecrets.externalSystemsExternalSecrets.secretStoreRef.name }}
    kind: SecretStore
  target:
    name: {{ $.Values.externalSecrets.externalSystemsExternalSecrets.target.name }}
  dataFrom:
  {{- if (index $.Values "external-systems") -}}
  {{- range $k,$v := index $.Values "external-systems" }}
  {{- if $v.auth }}{{- if $v.auth.type }}
  {{- if ne $v.auth.type "NO_AUTH" }}
  {{- if ne $k "diia" }}
    - extract:
        {{- $vaultPath := split ":" $v.auth.secret }}
        key: {{ print $vaultPath._1 }}
  {{- end -}}
  {{- end -}}
  {{- end -}}{{- end -}}
  {{- end -}}
  {{- end -}}
