{{- if and .Values.externalSecrets.enabled .Values.externalSecrets.manageGitProviderSecretsName }}
{{- $secretStore := include "edp-install.secretStoreName" . }}
{{- $awsSecretName := .Values.externalSecrets.manageGitProviderSecretsName }}
{{- range .Values.global.gitProviders }}
{{- $gitProvider := . }}
{{- if not (eq "gerrit" $gitProvider) }}
---
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
  name: ci-{{ $gitProvider }}
spec:
  target:
    template:
      metadata:
        labels:
          app.edp.epam.com/secret-type: repository
  refreshInterval: 1h
  secretStoreRef:
    kind: SecretStore
    name: {{ $secretStore }}
  data:
  - secretKey: token
    remoteRef:
      key: {{ $awsSecretName }}
      property: {{ $gitProvider }}-config.token
  - secretKey: id_rsa
    remoteRef:
      key: {{ $awsSecretName }}
      property: {{ $gitProvider }}-config.id_rsa
      decodingStrategy: Base64
  - secretKey: secretString
    remoteRef:
      key: {{ $awsSecretName }}
      property: {{ $gitProvider }}-config.secretString
{{- end }}
{{- end }}
{{- end }}
