{{- $name := include "webhooks-api.fullname" . -}}
{{- $sqlsrv := include "sql-name" . -}}
{{- $identity := include "url-of" (list .Values.app.ingress.entries.identity .) -}}
{{- $protocol := include "protocol" . -}}

apiVersion: v1
kind: ConfigMap
metadata:
  name: "cfg-{{ $name }}"
  labels:
    app: {{ template "webhooks-api.name" . }}
    chart: {{ template "webhooks-api.chart" .}}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
data:
  webhooks__ConnectionString: Server={{ $sqlsrv }};Initial Catalog={{ .Values.inf.sql.webhooks.db }};User Id={{ .Values.inf.sql.common.user }};Password={{ .Values.inf.sql.common.pwd }};TrustServerCertificate={{ .Values.inf.sql.common.TrustServerCertificate }};
  urls__IdentityUrl: http://{{ $identity }}
  urls__IdentityUrlExternal: {{ $protocol }}://{{ $identity }}
  all__EventBusConnection: {{ .Values.inf.eventbus.constr }}
  all__InstrumentationKey: "{{ .Values.inf.appinsights.key }}"
  all__UseAzureServiceBus: "{{ .Values.inf.eventbus.useAzure }}"