{{- $domains := .Values.domains -}}
{{- if .Values.global }}
  {{- if .Values.global.domains }}
    {{- $domains = .Values.global.domains -}}
  {{- end -}}
{{- end -}}

{{- if not $domains -}}
  {{- $name := (dict "name" (.Values.environment.ADDRESS | trimPrefix "https://" | trimPrefix "http://")) -}}
  {{- $domains = (list (merge .Values.environment $name)) -}}
{{- end -}}

{{- range $domains }}
---
apiVersion: v1
kind: Pod
metadata:
  name: "{{ include "layer1_port_owncloud.fullname" (mergeOverwrite $ .) }}-test-research"
  labels:
{{ include "layer1_port_owncloud.labels" (mergeOverwrite $ .) | indent 4 }}
  annotations:
    "helm.sh/hook": test-success
spec:
  containers:
    - name: wget
      image: busybox
      command: ['wget']
      args:  ['{{ include "layer1_port_owncloud.fullname" (mergeOverwrite $ .) }}:{{ $.Values.service.port }}']
  restartPolicy: Never
{{- end -}}
