{{- if and .Values.externalSecrets.enabled .Values.externalSecrets.manageEDPInstallSecrets ( index .Values "codebase-operator" "jira" "integration") }}
{{- $credentialName := index .Values "codebase-operator" "jira" "credentialName" }}
{{- $secretStore := include "edp-install.secretStoreName" . }}
{{- $awsSecretName := .Values.externalSecrets.manageEDPInstallSecretsName }}
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
  name: {{ $credentialName }}
spec:
  target:
    template:
      metadata:
        labels:
          app.edp.epam.com/secret-type: jira
  refreshInterval: 1h
  secretStoreRef:
    kind: SecretStore
    name: {{ $secretStore }}
  data:
  - secretKey: username
    remoteRef:
      key: {{ $awsSecretName }}
      property: {{ $credentialName }}.username
  - secretKey: password
    remoteRef:
      key: {{ $awsSecretName }}
      property: {{ $credentialName }}.password
{{- end }}
