apiVersion: v1
kind: ConfigMap
metadata:
  name: form-submission-validation-environment-js
  labels:
    {{- include "form-submission-validation.labels" . | nindent 4 }}
data:
  environment.js: |
    const ENVIRONMENT_VARIABLES = {
    {{- if .Values.environmentJs }}
    {{- range $key,$value := .Values.environmentJs }}
    {{- $tp := typeOf $value }}
    {{- if eq $tp "string" }}
      {{ $key }}: {{ tpl $value $ | squote }},
    {{- end }}
    {{- if eq $tp "[]interface {}" }}
      {{- $valuesElements := list }}
      {{- range $value }}
        {{- $valuesElements = append $valuesElements (. | squote) }}
      {{- end }}
      {{ $key }}: [{{ $valuesElements | join ", " }}],
    {{- end }}
    {{- end }}
    {{- end }}
    }
