sources:
{{- range $name, $val := .Values.global.storage.data }}
{{- $type := ($val.type | lower ) }}
  - type: {{ $type }}
    name: {{ $name }}
    filter: {{ .filter }}
    kwargs:
    {{- if eq $type "swift" }}
      username: {{ template "vs-registrar.envVarQuote" $val.username }}
      password: {{ template "vs-registrar.envVarQuote" $val.password }}
      project_name: {{ template "vs-registrar.envVarQuote" $val.project_name }}
      project_id: {{ template "vs-registrar.envVarQuote" $val.project_id }}
      region_name: {{ template "vs-registrar.envVarQuote" $val.region_name }}
      auth_url: {{ template "vs-registrar.envVarQuote" $val.auth_url }}
      auth_version: {{ $val.auth_version }}
      user_domain_name: {{ template "vs-registrar.envVarQuote" $val.user_domain_name }}
      user_domain_id: {{ template "vs-registrar.envVarQuote" $val.user_domain_id }}
      project_domain_name: {{ template "vs-registrar.envVarQuote" $val.project_domain_name }}
      project_domain_id: {{ template "vs-registrar.envVarQuote" $val.project_domain_id }}
      {{- if $val.container }}
      container: {{ template "vs-registrar.envVarQuote" $val.container }}
      {{- end }}
    {{- end }}
    {{- else if eq $type "s3" }}
      bucket_name: {{ $val.bucket | default "null" }}
      endpoint_url: {{ $val.endpoint_url | default "null" }}
      access_key_id: {{ $val.access_key_id }}
      public: {{ $val.public | default "false" }}
      region_name: {{ $val.region_name }}
      secret_access_key: {{ $val.secret_access_key }}
      validate_bucket_name: {{ if hasKey $val "validate_bucket_name" }}{{ $val.validate_bucket_name }}{{ else }}true{{ end }}
    {{- end }}
    {{- else if eq $type "http" }}
      endpoint_url: {{ $val.endpoint_url | default "null" }}
    {{- end }}
{{- end }}

backends:
  {{- if not ( .Values.config.disableDefaultEoxserver ) }}
  - type: eoxserver
    path: registrar.backend.eoxserver.EOxServerBackend
    kwargs:
      instance_base_path: {{ .Values.config.eoxserverInstanceBasePath }}
      instance_name: {{ .Values.config.eoxserverInstanceName }}
      product_types:
      {{- range $prod_type_val := .Values.global.productTypes -}}
      {{- $prod_type_val := unset $prod_type_val "browses" }}
      {{- $prod_type_val := unset $prod_type_val "defaultBrowse" }}
      -{{- toYaml $prod_type_val | nindent 10 -}}
      {{- end -}}
  {{- end }}
  {{- range .Values.config.backends }}
  -{{ toYaml . | nindent 6 }}
  {{- end }}

{{- if not (empty .Values.config.pathBackends) }}
path_backends:
{{- range .Values.config.pathBackends }}
-{{ toYaml . | nindent 6 }}
{{- end }}
{{- end }}

{{- if not (empty .Values.config.preHandlers) }}
pre_handlers:
  {{- toYaml .Values.config.preHandlers | nindent 4 -}}
{{- end }}

{{- if not (empty .Values.config.postHandlers) }}
post_handlers:
  {{- toYaml .Values.config.postHandlers | nindent 4 -}}
{{- end }}
