CHART NAME: {{ .Chart.Name  }}
CHART VERSION: {{ .Chart.Version  }}
APP VERSION: {{ .Chart.AppVersion  }}

** Please be patient while the chart is being deployed **

1. Access your EODAG Server installation:

{{- if .Values.ingress.enabled }}
  Connect to one of the following hosts:
  {{ if .Values.ingress.tls }}
    https://{{ .Values.ingress.hostname }}
  {{- else }}
    http://{{ .Values.ingress.hostname }}
  {{- end }}
{{- else }}
  Execute the following commands:
{{- if contains "NodePort" .Values.service.type }}
  export NODE_PORT=$(kubectl get --namespace {{ include "common.names.namespace" . }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "common.names.fullname" . }})
  export NODE_IP=$(kubectl get nodes --namespace {{ include "common.names.namespace" . }} -o jsonpath="{.items[0].status.addresses[0].address}")
  export URL="http://${NODE_IP}:${NODE_PORT}/"
  echo "EODAG Server URL: http://$NODE_IP:$NODE_PORT/"

{{- else if contains "LoadBalancer" .Values.service.type }}

** Please ensure an external IP is associated to the {{ include "common.names.fullname" . }} service before proceeding **
** Watch the status using: kubectl get svc --namespace {{ include "common.names.namespace" . }} -w {{ include "common.names.fullname" . }} **

  export SERVICE_IP=$(kubectl get svc --namespace {{ include "common.names.namespace" . }} {{ include "common.names.fullname" . }} --template "{{ "{{ range (index .status.loadBalancer.ingress 0) }}{{ . }}{{ end }}" }}")

{{- $port:=.Values.service.ports.http | toString }}
  export URL="http://${SERVICE_IP}{{- if ne $port "80" }}:{{ .Values.service.ports.http }}{{ end }}"
  echo "EODAG Server URL: http://$SERVICE_IP{{- if ne $port "80" }}:{{ .Values.service.ports.http }}{{ end }}/"

{{- else if contains "ClusterIP" .Values.service.type }}

  kubectl port-forward --namespace {{ include "common.names.namespace" . }} svc/{{ include "common.names.fullname" . }} 8080:{{ .Values.service.ports.http }} &
  export URL=http://127.0.0.1:8080/
  echo "EODAG Server URL: http://127.0.0.1:8080/"
{{- end }}
{{- end }}
