{{- define "neo4j.headlessService.namespaceParameter" -}}
{{ if ne "default" .Release.Namespace }} --namespace "{{.Release.Namespace}}"{{ end }}
{{- end -}}

{{- define "neo4j.headlessService.logPassword" -}}
{{ if .Values.logInitialPassword }}{{ .Values.neo4j.password }}{{ else }}**********{{ end }}
{{- end -}}

{{- $authDisabled := index .Values.config "dbms.security.auth_enabled" | default "" | regexMatch "(?i)no|false" -}}
{{- $boltPort := .Values.ports.bolt.port | default "7687" }}
{{- $ignored := set .Values.neo4j "acceptLicenseAgreement" "yes" }}

{{- if .Release.IsInstall -}}

Thank you for installing {{ .Chart.Name }}.

Your release "{{ .Release.Name }}" has been installed in namespace "{{ .Release.Namespace }}".

{{ else -}}

You have updated {{ .Chart.Name }} in namespace "{{ .Release.Namespace }}".

{{ end -}}

Once rollout is complete you can connect to your Neo4j cluster using "neo4j://{{ .Release.Name }}-neo4j.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}:{{ $boltPort }}". Try:

  $ kubectl run --rm -it{{ template "neo4j.headlessService.namespaceParameter" . }} --image "{{ template "neo4j.headlessService.image" . }}" cypher-shell \
     -- cypher-shell -a "neo4j://{{ template "neo4j.headlessService.name" . }}-headless.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}:{{ $boltPort }}"{{ if not $authDisabled | and .Values.neo4j.password |and .Values.logInitialPassword}} -u neo4j -p "{{ template "neo4j.headlessService.logPassword" . }}"{{ end }}

Graphs are everywhere!
