{{- if .Values.secret.createSecret -}}
{{- $authenticationType := .Values.gateway.auth.type | required ".Values.gateway.auth.type is required." -}}
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "azure-api-management-gateway.fullname" . }}
  namespace: {{ .Release.Namespace | quote }}
  labels:
    {{- include "azure-api-management-gateway.labels" . | nindent 4 }}
type: Opaque
data:
  {{- if eq (lower $authenticationType) "gatewaytoken" }}
  {{- $gatewayToken := .Values.gateway.auth.key | required "No gateway token was specified in gateway.auth.key." }}
  gateway-key: {{ $gatewayToken | b64enc | quote }}
  {{- end }}
  {{- if eq (lower $authenticationType) "azureadapp" }}
  {{- $adAppSecret := .Values.gateway.auth.azureAd.app.secret | required "No Azure AD application secret was specified in gateway.auth.azureAd.app.secret." }}
  azure-ad-app-secret: {{ $adAppSecret | b64enc | quote }}
  {{- end }}
{{- end }}
