{{- $enabled := eq (include "osdu-developer-service.isEnabled" .) "1" -}}
{{- if and $enabled .Values.azure }}
{{- if and .Values.azure.vault }}
---
apiVersion: secrets-store.csi.x-k8s.io/v1alpha1
kind: SecretProviderClass
metadata:
  name: azure-keyvault
spec:
  provider: azure
  secretObjects:
  {{- range .Values.azure.vault.secret }}
  - secretName: {{ .name }}
    type: Opaque
    data:
    - objectName: {{ .value | quote }}
      key: {{ .key }}
  {{- end }}
  parameters:
    usePodIdentity: "true"
    useVMManagedIdentity: "false"
    userAssignedIdentityId: ""
    resourceGroup: "{{ .Values.azure.vault.group }}"
    keyvaultName: "{{ .Values.azure.vault.name }}"
    subscriptionId: "{{ .Values.azure.subscription }}"
    tenantId: "{{ .Values.azure.tenant }}"
    clientId: {{ .Values.azure.clientId }}
    objects: |
      array:
        {{- range .Values.azure.vault.secret }}
        - |
          objectName: {{ .value }}
          objectType: secret
        {{- end }}
{{- end }}
{{- end }}
