Release Name: {{ .Release.Name }}
StackGres Version: {{ .Chart.Version }}

   _____ _             _     _____
  / ____| |           | |   / ____|
 | (___ | |_ __ _  ___| | _| |  __ _ __ ___  ___
  \___ \| __/ _` |/ __| |/ / | |_ | '__/ _ \/ __|
  ____) | || (_| | (__|   <| |__| | | |  __/\__ \
 |_____/ \__\__,_|\___|_|\_\\_____|_|  \___||___/
                                  by OnGres, Inc.
{{- if not .Values.cert.autoapprove }}

To complete the process approve operator certificate signing request:

    kubectl certificate approve {{ .Release.Name }}
{{- end }}

Check if the operator was successfully deployed and is available:

    kubectl describe deployment -n {{ .Release.Namespace }} {{ .Release.Name }}

    kubectl wait -n {{ .Release.Namespace }} deployment/{{ .Release.Name }} --for condition=Available

Check if the restapi was successfully deployed and is available:

    kubectl describe deployment -n {{ .Release.Namespace }} {{ .Values.restapi.name }}

    kubectl wait -n {{ .Release.Namespace }} deployment/{{ .Values.restapi.name }} --for condition=Available

{{- if .Values.deploy.restapi }}
To access StackGres Operator UI from localhost, run the below commands:

    POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ .Values.restapi.name }}" -o jsonpath="{.items[0].metadata.name}")

    kubectl port-forward "$POD_NAME" 8443:9443 --namespace {{ .Release.Namespace }}

Read more about port forwarding here: http://kubernetes.io/docs/user-guide/kubectl/kubectl_port-forward/

Now you can access the StackGres Operator UI on:

https://localhost:8443

{{- if (eq .Values.authentication.type "jwt") }}
To get the username, run the command:

    kubectl get secret -n {{ .Release.Namespace }} {{ .Values.authentication.secretRef.name | default .Values.restapi.name }} --template '{{ "{{" }} printf "username = %s\n" (.data.k8sUsername | base64decode) {{ "}}" }}'
{{- if and (not .Values.authentication.password) (not .Values.authentication.secretRef.name) }}

To get the generated password, run the command:

    kubectl get secret -n {{ .Release.Namespace }} {{ .Values.restapi.name }} --template '{{ "{{" }} printf "password = %s\n" (.data.clearPassword | base64decode) {{ "}}" }}'

Remember to remove the generated password hint from the secret to avoid security flaws:

    kubectl patch secrets --namespace {{ .Release.Namespace }} {{ .Values.restapi.name }} --type json -p '[{"op":"remove","path":"/data/clearPassword"}]'
{{- end }}
{{- end }}
{{- end }}
