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

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

{{- $dbSecretName := include "node.mongodb.fullname" . -}}

1. Get the URL of your Node app  by running:

{{- if eq .Values.service.type "NodePort" }}

  export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "common.names.fullname" . }})
  export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
  echo "Node app URL: http://$NODE_IP:$NODE_PORT/"

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

  NOTE: It may take a few minutes for the LoadBalancer IP to be available.
        Watch the status with: 'kubectl get svc -w {{ template "common.names.fullname" . }} --namespace {{ .Release.Namespace }}'

  export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "common.names.fullname" . }} --template "{{ "{{ range (index .status.loadBalancer.ingress 0) }}{{ . }}{{ end }}" }}")
  echo "Node app URL: http://$SERVICE_IP/"

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

  kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{ template "common.names.fullname" . }} {{ .Values.service.port  }}:{{ .Values.service.port }}
  echo "Node app URL: http://127.0.0.1:{{ .Values.service.port }}/"

{{- end }}

{{- include "node.checkRollingTags" . }}
{{- include "node.validateValues" . }}

{{- $passwordValidationErrors := list }}

{{- if .Values.mongodb.enabled }}
{{- $dbPasswordValidationErrors := include "common.validations.values.mongodb.passwords" (dict "secret" $dbSecretName "subchart" true "context" $) -}}
{{- $passwordValidationErrors = append $passwordValidationErrors $dbPasswordValidationErrors -}}
{{- end }}

{{- include "common.errors.upgrade.passwords.empty" (dict "validationErrors" $passwordValidationErrors "context" $) -}}
