{{- $hostName := pluck "hostName" .Values.global .Values | compact | first }}
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
  http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $hostName }}{{ .Values.feAdministrator.url.base }}/
{{- else if contains "NodePort" .Values.service.type }}
  export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "ilm.fullname" . }})
  export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
  echo http://$NODE_IP:$NODE_PORT{{ .Values.feAdministrator.url.base }}/

  You need a valid certificate to be provided in the X-APP-CERTIFICATE header.
{{- else if contains "LoadBalancer" .Values.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 "ilm.fullname" . }}'
  export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "ilm.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
  echo http://$SERVICE_IP:{{ .Values.service.port }}{{ .Values.feAdministrator.url.base }}/

  You need a valid certificate to be provided in the X-APP-CERTIFICATE header.
{{- else if contains "ClusterIP" .Values.service.type }}
  export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ template "api-gateway-kong.name" .Subcharts.apiGateway }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
  export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
  echo "Visit http://127.0.0.1:8080{{ .Values.feAdministrator.url.base }}/ to use your application"
  kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT

  You need a valid certificate to be provided in the X-APP-CERTIFICATE header.
{{- end }}

{{ if and (.Values.registerAdmin.enabled) (eq .Values.registerAdmin.source "generated") }}
2. Get the administrator certificate using these commands:

  pkcs12: kubectl get secrets --namespace {{ .Release.Namespace }} admin-secret -o jsonpath='{.data.pkcs12}' | base64 --decode > admin-certificate.p12
  password: kubectl get secrets --namespace {{ .Release.Namespace }} admin-secret -o jsonpath='{.data.password}' | base64 --decode

  internal CA certificate: kubectl get secrets --namespace {{ .Release.Namespace }} admin-ca-keypair -o jsonpath='{.data.tls\.crt}' | base64 --decode > admin-ca-certificate.pem
  When you want to keep access for the generated administrator, do not forget to include this CA certificate into the list of trusted certificates!

  Import the certificate to your browser!
{{- end }}

{{- $workloadType := include "ilm.workloadType" . }}
{{- include "ilm.core.validateAutoscaling" . }}
{{- $multiReplica := eq (include "ilm.core.multiReplica" .) "true" }}
{{- if and (eq $workloadType "Deployment") $multiReplica }}

!! WARNING: Core is configured to potentially run more than one replica, but not safely

   You have set replicaCount > 1 (or autoscaling with maxReplicas > 1), and Core is
   configured as a Deployment (workloadType: "Deployment"). This combination is unsafe.

   A Deployment gives its replicas no stable identity, so there is no safe automatic
   way to assign each replica a unique instance id. Instead, each replica derives its
   id from its pod IP, and two replicas can end up with the SAME id. When that happens,
   they produce duplicate certificate serial numbers, which is not allowed and can break
   trust in the serialnumbers Core issues to timestamps.

   !! ACTION REQUIRED: switch to StatefulSet

      Set workloadType: "StatefulSet" in your values. A StatefulSet assigns each replica
      a stable ordinal (0, 1, 2, …) and Core uses that ordinal as its unique instance id —
      no collisions are possible, and the id survives pod restarts and rescheduling.

      Example:
        workloadType: "StatefulSet"

   Alternatively, reduce to a single replica (replicaCount: 1) and optionally pin its
   id with `platformInstanceId` if you need a specific value.

   Until you act, any replica beyond the first will start with a warning in its log and
   use a pod-IP-derived id that may collide.
{{- end }}

DO NOT FORGET TO SAVE YOUR CONFIGURATION, YOU WILL NEED IT!
