{{- define "tle-monitoring-service.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{- define "tle-monitoring-service.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- include "tle-monitoring-service.name" . | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}

{{- define "tle-monitoring-service.labels" -}}
app.kubernetes.io/name: {{ include "tle-monitoring-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 "tle-monitoring-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 "tle-monitoring-service.managementBaseUrl" -}}
{{- if .Values.app.managementBaseUrl -}}
{{- .Values.app.managementBaseUrl -}}
{{- else -}}
{{- printf "http://%s:%v" (include "tle-monitoring-service.fullname" .) .Values.service.port -}}
{{- end -}}
{{- end -}}

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