{{- $namespace := .Release.Namespace -}}
{{- $scope := $ -}}
{{- range $key, $enable := .Values.application.names }}
{{- if $enable -}}
{{- $applicationName := $key | trunc 63 }}
---
apiVersion: v1
kind: Pod
metadata:
  name: "{{ $applicationName }}-test-connection"
  namespace: {{ $namespace }}
  labels:
    type: {{ $.Values.application.type }}
    app: {{ $applicationName }}
    helm.sh/chart: {{ include "frontend-app.chart" $scope }}
    app.kubernetes.io/managed-by: {{ $.Release.Service }}
    {{- if $.Chart.AppVersion }}
    app.kubernetes.io/version: {{ $.Chart.AppVersion | quote }}
    {{- end }}
  annotations:
    "helm.sh/hook": test-success
spec:
  containers:
    - name: wget
      image: busybox
      command: ['wget']
      args: ['{{ $applicationName }}:{{ $.Values.service.ports.port }}']
  restartPolicy: Never
---
{{- end }}
{{- end }}
