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.

{{- $releaseNamespace := .Release.Namespace }}
{{- $clusterDomain := .Values.clusterDomain }}
{{- $fullname := include "concourse.web.fullname" . }}
{{- $concourseWebSecretName := include "concourse.web.secretName" . }}

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

{{- if .Values.diagnosticMode.enabled }}

The chart has been deployed in diagnostic mode. All probes have been disabled and the command has been overwritten with:

  command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 4 }}
  args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 4 }}

Get the list of pods by executing:

    kubectl get pods --namespace {{ $releaseNamespace }} -l app.kubernetes.io/instance={{ .Release.Name }}

Access the pod you want to debug by executing

    kubectl exec --namespace {{ $releaseNamespace }} -ti <NAME OF THE POD> -- bash

{{- else }}

{{- if empty (include "concourse.host" .) }}
###############################################################################
### ERROR: You did not provide an external host in your 'helm install' call ###
###############################################################################

This deployment will be incomplete until you configure Concourse with a resolvable
host. To configure Concourse with the URL of your service:

1. Get the Concourse URL by running:

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

    export APP_PORT=$(kubectl get svc --namespace {{ $releaseNamespace }} {{ include "concourse.web.fullname" . }} -o jsonpath="{.spec.ports[0].nodePort}")
    export APP_HOST=$(kubectl get nodes --namespace {{ $releaseNamespace }} -o jsonpath="{.items[0].status.addresses[0].address}")

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

  NOTE: It may take a few minutes for the LoadBalancer IP to be available.
        Watch the status with: 'kubectl get svc --namespace {{ $releaseNamespace }} -w {{ include "concourse.web.fullname" . }}'

    export APP_HOST=$(kubectl get svc --namespace {{ $releaseNamespace }} {{ include "concourse.web.fullname" . }} --template "{{ "{{ range (index .status.loadBalancer.ingress 0) }}{{ . }}{{ end }}" }}")

  {{- end }}

2. Complete your Concourse deployment by running:

  {{- if .Values.postgresql.enabled }}

    {{- if and .Values.secrets.localAuth.enabled }}
    {{ include "common.utils.secret.getvalue" (dict "secret" $concourseWebSecretName "field" "local_users" "context" $) }}
    {{- end }}
    helm upgrade --namespace {{ $releaseNamespace }} {{ .Release.Name }} oci://registry-1.docker.io/bitnamicharts/{{ .Chart.Name }} \
      {{- if and .Values.secrets.localAuth.enabled }}
      --set secrets.localUsers=$LOCAL_USERS \
      {{- end }}
      {{- if .Values.global }}
      {{- if .Values.global.imagePullSecrets }}
      --set global.imagePullSecrets={{ .Values.global.imagePullSecrets }} \
      {{- end }}
      {{- end }}
      --set service.web.type={{ .Values.service.web.type }} \
      --set web.externalUrl=$APP_HOST

  {{- else }}

    ## PLEASE UPDATE THE EXTERNAL DATABASE CONNECTION PARAMETERS IN THE FOLLOWING COMMAND AS NEEDED ##
    helm upgrade --namespace {{ $releaseNamespace }} {{ .Release.Name }} oci://registry-1.docker.io/bitnamicharts/{{ .Chart.Name }} \
      {{- if and .Values.secrets.localAuth.enabled }}
      --set secrets.localUsers=$LOCAL_USERS \
      {{- end }}
      {{- if not (empty .Values.externalDatabase.host) }}
      --set externalDatabase.host={{ .Values.externalDatabase.host }} \
      {{- end }}
      {{- if not (empty .Values.externalDatabase.user) }}
      --set externalDatabase.user={{ .Values.externalDatabase.user }} \
      {{- end }}
      {{- if not (empty .Values.externalDatabase.password) }}
      --set externalDatabase.password={{ .Values.externalDatabase.password }} \
      {{- end }}
      {{- if not (empty .Values.externalDatabase.database) }}
      --set externalDatabase.database={{ .Values.externalDatabase.database }} \
      {{- end }}
      {{- if .Values.global }}
      {{- if .Values.global.imagePullSecrets }}
      --set global.imagePullSecrets={{ .Values.global.imagePullSecrets }} \
      {{- end }}
      {{- end }}
      --set postgresql.enabled=false \
      --set service.web.type={{ .Values.service.web.type }} \
      --set web.externalUrl=$APP_HOST

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

Get your Concourse login credentials by running:

    echo "Username : Password
-------------------
$(kubectl get secret --namespace {{ $releaseNamespace }} {{ $concourseWebSecretName }} -o jsonpath="{.data.local_users}" | base64 -d)"

Concourse can be accessed via port {{ .Values.web.containerPorts.http }}: on the following DNS name from within your cluster:

    {{ printf "%s.%s.svc.%s" $fullname $releaseNamespace $clusterDomain }}

To connect to Concourse from outside the cluster, perform the following steps:

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

1. Get the Concourse 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 "Concourse URL: http{{ if .Values.ingress.tls }}s{{ end }}://{{ .Values.ingress.hostname }}"
    echo "$CLUSTER_IP  {{ .Values.ingress.hostname }}" | sudo tee -a /etc/hosts

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

1.  Create a port-forward to the service:

    kubectl port-forward --namespace {{ $releaseNamespace }} svc/{{ $fullname }} {{ .Values.service.web.ports.http }}:{{ .Values.service.web.ports.http }} &
    echo "Concourse URL: http://127.0.0.1:{{ .Values.service.web.ports.http }}"

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

1. Obtain the NodePort IP and port:

    export NODE_IP=$(kubectl get nodes --namespace {{ $releaseNamespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
    export NODE_PORT=$(kubectl get --namespace {{ $releaseNamespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ $fullname }})
    echo "Concourse URL: http://${NODE_IP}:$NODE_PORT"

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

1. Obtain the LoadBalancer IP:

  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 {{ $fullname }}'

    export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ $fullname }} --template "{{ "{{ range (index .status.loadBalancer.ingress 0) }}{{ . }}{{ end }}" }}")
    echo "Concourse URL: http://${SERVICE_IP}:{{ .Values.service.web.ports.http }}"

{{- end }}

2. Open a browser and access Concourse using the obtained URL. If this is your first time using Concourse, follow the examples at https://concourse-ci.org/examples.html

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

{{- include "concourse.validateValues" . }}
{{- if .Values.web.conjur.enabled -}}
{{- include "concourse.web.conjur.validateValues" . }}
{{- end }}
{{- include "common.warnings.rollingTag" .Values.image }}
{{- include "common.warnings.rollingTag" .Values.volumePermissions.image }}

{{- $passwordValidationErrors := list -}}
{{- if and .Values.secrets.localAuth.enabled (not .Values.web.existingSecret) -}}
    {{- $secretName := include "concourse.web.secretName" . -}}
    {{- $requiredWebPassword := dict "valueKey" "secrets.localUsers" "secret" $secretName "field" "local_users" "context" $ -}}
    {{- $requiredWebPasswordError := include "common.validations.values.single.empty" $requiredWebPassword -}}
    {{- $passwordValidationErrors = append $passwordValidationErrors $requiredWebPasswordError -}}
{{- end }}
{{- include "common.errors.upgrade.passwords.empty" (dict "validationErrors" $passwordValidationErrors "context" $) -}}
{{- include "common.warnings.resources" (dict "sections" (list "volumePermissions" "web" "worker") "context" $) }}
{{- include "common.warnings.modifiedImages" (dict "images" (list .Values.image .Values.volumePermissions.image) "context" $) }}
{{- include "common.errors.insecureImages" (dict "images" (list .Values.image .Values.volumePermissions.image) "context" $) }}
