{{- if .Values.ec2Locations.enabled }}
{{- if not .Values.ec2Locations.customUserDataSecret }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ printf "%s-%s" .Release.Name "user-data"  }}
  labels:
    app: {{ printf "%s-%s" .Release.Name "user-data"  }}
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    release: "{{ .Release.Name }}"
    heritage: "{{ .Release.Service }}"
type: Opaque
data:
  ec2_locations: {{ "1"  | toString | b64enc | quote }}
  ec2: {{ "1"  | toString | b64enc | quote }}
{{- if .Values.agentIngress.enabled }}
  {{- range $host := .Values.agentIngress.hosts }}
  host: {{ $host | toString | b64enc | quote }}
  {{- end }}
{{- else }}

{{- if .Values.ingress.enabled -}}
  {{- range $host := .Values.ingress.hosts }}
  host: {{ $host | toString | b64enc | quote }}
  {{- end }}
{{- end }}
{{- end }}

{{- range $name, $value := .Values.ec2Locations.userData }}
{{- if not (empty $value) }}
{{- if not (eq $name "enabled") }}
  {{ $name }}: {{ $value  | toString | b64enc | quote }}
{{- end }}
{{- end }}
{{- end }}


{{- end }}
{{- end }}
