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

Did you know there are enterprise versions of the Bitnami catalog? For enhanced secure software supply chain features, unlimited pulls from Docker, LTS support, or application customization, see Bitnami Premium or Tanzu Application Catalog. See https://www.arrow.com/globalecs/na/vendors/bitnami for more information.

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

{{- if and .Values.waitForBackends.enabled (not .Values.rbac.create) (not .Values.serviceAccount.create) }}
---------------------------------------------------------------------------------------------
 WARNING

    By specifying "rbac.create=false" and "serviceAccount.create=false" it's
    likely your pods enter into a "Init:CrashLoopBackOff" status if your
    K8s cluster has RBAC enabled.

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

Spring Cloud Data Flow chart was deployed enabling the following components:

- Spring Cloud Data Flow server
{{- if or .Values.skipper.enabled .Values.server.configuration.streamingEnabled }}
- Spring Cloud Skipper server
{{- end }}

Spring Cloud Data Flow can be accessed through the following DNS name from within your cluster:

    {{ include "scdf.server.fullname" . }}.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }} (port {{ coalesce .Values.server.service.ports.http .Values.server.service.port }})

To access Spring Cloud Data Flow dashboard from outside the cluster execute the following commands:

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

1. Get the Data Flow dashboard URL and associate its hostname to your cluster external IP:

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

{{- else }}

1. Get the Data Flow dashboard URL by running these commands:

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

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

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

  NOTE: It may take a few minutes for the LoadBalancer IP to be available.
        You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "scdf.server.fullname" . }}'

    export SERVICE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].port}" services {{ include "scdf.server.fullname" . }})
    export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "scdf.server.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
    echo "http://${SERVICE_IP}:${SERVICE_PORT}/dashboard"

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

    export SERVICE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].port}" services {{ include "scdf.server.fullname" . }})
    kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{ include "scdf.server.fullname" . }} ${SERVICE_PORT}:${SERVICE_PORT} &
    echo "http://127.0.0.1:${SERVICE_PORT}/dashboard"

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

2. Open a browser and access the Data Flow dashboard using the obtained URL.

{{- include "common.warnings.rollingTag" .Values.server.image }}
{{- include "common.warnings.rollingTag" .Values.server.composedTaskRunner.image }}
{{- include "common.warnings.rollingTag" .Values.skipper.image }}
{{- include "common.warnings.rollingTag" .Values.waitForBackends.image }}
{{- include "scdf.validateValues" . }}

{{- $passwordErrors := list -}}
{{- $secretNameMariadb := include "scdf.mariadb.fullname" . -}}
{{- $secretNameRabbitmq := include "scdf.rabbitmq.secretName" . -}}
{{- $existingRabbitmqSecret := coalesce .Values.externalRabbitmq.existingSecret .Values.externalRabbitmq.existingPasswordSecret -}}

{{/* Mysql required password */}}
{{- $passwordMysqlErrors := include "common.validations.values.mariadb.passwords" (dict "secret" $secretNameMariadb "subchart" true "context" $) -}}
{{- $passwordErrors = append $passwordErrors $passwordMysqlErrors -}}

{{/* Rabbitmq required password */}}
{{- if or .Values.rabbitmq.enabled (and .Values.externalRabbitmq.enabled (not $existingRabbitmqSecret)) -}}
  {{- $rabbitmqValidations := list -}}
  {{- $passwordValueKey := ternary "rabbitmq.auth.password" "externalRabbitmq.password" .Values.rabbitmq.enabled }}
  {{- $rabbitmqValidations = append $rabbitmqValidations (dict "valueKey" $passwordValueKey "secret" $secretNameRabbitmq "field" "rabbitmq-password") -}}
  {{- if .Values.rabbitmq.enabled -}}
    {{- $rabbitmqValidations = append $rabbitmqValidations (dict "valueKey" "rabbitmq.auth.erlangCookie" "secret" $secretNameRabbitmq "field" "rabbitmq-erlang-cookie") -}}
  {{- end -}}
  {{- $requiredRabbitmqPasswordErrors := include "common.validations.values.multiple.empty" (dict "required" $rabbitmqValidations "context" $) -}}
  {{- $passwordErrors =  append $passwordErrors $requiredRabbitmqPasswordErrors -}}
{{- end }}

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

{{- if .Release.IsUpgrade -}}
  {{- $passwordWarnings := list -}}

  {{- if not .Values.mariadb.enabled -}}
    {{- $secretNameServerExternalDb := printf "%s-externaldb" (include "scdf.server.fullname" .) -}}
    {{- $requiredServerExternalDbPassword := dict "valueKey" "externalDatabase.dataflow.password" "secret" $secretNameServerExternalDb "field" "datasource-password" -}}
    {{- $passwordWarnings = append $passwordWarnings $requiredServerExternalDbPassword -}}
    {{- $secretNameSkipperExternalDb := printf "%s-externaldb" (include "scdf.skipper.fullname" .) -}}
    {{- $requiredSkipperExternalDbPassword := dict "valueKey" "externalDatabase.skipper.password" "secret" $secretNameSkipperExternalDb "field" "datasource-password" -}}
    {{- $passwordWarnings = append $passwordWarnings $requiredSkipperExternalDbPassword -}}
  {{- end -}}
  {{- if and .Values.externalRabbitmq.enabled (not .Values.rabbitmq.enabled) (not $existingRabbitmqSecret) -}}
    {{- $requiredExternalRabbitmqPassword := dict "valueKey" "externalRabbitmq.password" "secret" $secretNameRabbitmq "field" "rabbitmq-password" -}}
    {{- $passwordWarnings = append $passwordWarnings $requiredExternalRabbitmqPassword -}}
  {{- end -}}

  {{- if not (empty $passwordWarnings) -}}
WARNING: Review values for the following password in the command, if they are correct please ignore this notice.
    {{- include "common.validations.values.multiple.empty" (dict "required" $passwordWarnings "context" $) -}}
  {{- end -}}
{{- end -}}
{{- include "common.warnings.resources" (dict "sections" (list "deployer" "metrics" "server" "skipper" "waitForBackends") "context" $) }}
{{- include "common.warnings.modifiedImages" (dict "images" (list .Values.server.image .Values.server.composedTaskRunner.image .Values.skipper.image .Values.metrics.image .Values.waitForBackends.image .Values.mariadb.image) "context" $) }}
{{- include "common.errors.insecureImages" (dict "images" (list .Values.server.image .Values.server.composedTaskRunner.image .Values.skipper.image .Values.metrics.image .Values.waitForBackends.image .Values.mariadb.image) "context" $) }}
