{{- define "pcp-coverage-scheme-service.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{- define "pcp-coverage-scheme-service.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- include "pcp-coverage-scheme-service.name" . | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}

{{- define "pcp-coverage-scheme-service.labels" -}}
app.kubernetes.io/name: {{ include "pcp-coverage-scheme-service.name" . }}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}

{{- define "pcp-coverage-scheme-service.serviceBaseUrl" -}}
{{- if .Values.app.serviceBaseUrl -}}
{{- .Values.app.serviceBaseUrl -}}
{{- else if and .Values.ingress.enabled .Values.ingress.host -}}
{{- $scheme := .Values.app.serviceBaseUrlScheme | default (ternary "https" "http" (gt (len .Values.ingress.tls) 0)) -}}
{{- printf "%s://%s" $scheme .Values.ingress.host -}}
{{- end -}}
{{- end -}}

{{- define "pcp-coverage-scheme-service.managementBaseUrl" -}}
{{- if .Values.app.managementBaseUrl -}}
{{- .Values.app.managementBaseUrl -}}
{{- else -}}
{{- printf "http://%s:%v" (include "pcp-coverage-scheme-service.fullname" .) .Values.service.port -}}
{{- end -}}
{{- end -}}

{{- define "pcp-coverage-scheme-service.healthUrl" -}}
{{- if .Values.app.healthUrl -}}
{{- .Values.app.healthUrl -}}
{{- else -}}
{{- printf "%s/actuator/health" (include "pcp-coverage-scheme-service.managementBaseUrl" .) -}}
{{- end -}}
{{- end -}}
