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

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

Obtain the Argo Workflows UI URL:

{{- if .Values.ingress.enabled }}

  export CLUSTER_IP=$(minikube ip) # On Minikube. Use: `kubectl cluster-info` on others K8s clusters
  echo "Argo Workflows UI URL: http{{ if .Values.ingress.tls }}s{{ end }}://{{ .Values.ingress.hostname }}/"
  echo "$CLUSTER_IP  {{ .Values.ingress.hostname }}" | sudo tee -a /etc/hosts

{{- else }}

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

  kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{ include "argo-workflows.server.fullname" . }} 8080:{{ .Values.server.service.ports.http }} &
  echo "Argo Workflows UI URL: http://127.0.0.1:8080/"

{{- else if contains "NodePort" .Values.server.service.type }}

  export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "argo-workflows.server.fullname" . }})
  export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
  echo "Argo Workflows UI URL: http://$NODE_IP:$NODE_PORT/"

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

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

  export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "argo-workflows.server.fullname" . }} --template "{{ "{{ range (index .status.loadBalancer.ingress 0) }}{{ . }}{{ end }}" }}")
  echo "Argo Workflows UI URL: http://$SERVICE_IP:{{ .Values.server.service.ports.http }}/"

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

{{- if and .Values.server.auth.enabled (contains .Values.server.auth.mode "client") }}

Obtain the Argo Workflows access token:

  SECRET=$(kubectl get sa {{ include "argo-workflows.server.serviceAccountName" . }} -o=jsonpath='{.secrets[0].name}')
  ARGO_TOKEN="Bearer $(kubectl get secret $SECRET -o=jsonpath='{.data.token}' | base64 -d)"
  echo "$ARGO_TOKEN"

{{- end }}

{{- if .Release.IsUpgrade -}}
{{- $passwordValidationErrors := list -}}
{{- if and .Values.mysql.enabled (not .Values.mysql.auth.password) -}}
{{- $passwordValidationErrors = append $passwordValidationErrors "Missing 'mysql.auth.password', please use the same than the current one" -}}
{{- end -}}
{{- if and .Values.externalDatabase.enabled (not .Values.externalDatabase.password) (not .Values.externalDatabase.existingSecret) -}}
{{- $passwordValidationErrors = append $passwordValidationErrors "Missing 'externalDatabase.password', please use the same than the current one" -}}
{{- end -}}
{{- end -}}

{{- include "common.warnings.rollingTag" .Values.server.image }}
{{- include "common.warnings.rollingTag" .Values.controller.image }}
{{- include "common.warnings.rollingTag" .Values.executor.image }}
{{- include "argo-workflows.validateValues" . }}
{{- include "common.warnings.resources" (dict "sections" (list "controller" "executor" "server") "context" $) }}
