helm-charts/charts/library/common/templates/lib/service/_getPortNumberByName.tpl
Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs 98677d85b2
feat(common): Release 2.0.0 (#189)
2023-10-02 13:21:17 +02:00

17 lines
576 B
Smarty

{{/*
Return a service port number by name for a Service object
*/}}
{{- define "bjw-s.common.lib.service.getPortNumberByName" -}}
{{- $rootContext := .rootContext -}}
{{- $identifier := .serviceID -}}
{{- $portName := .portName -}}
{{- $service := include "bjw-s.common.lib.service.getByIdentifier" (dict "rootContext" $rootContext "id" $identifier) | fromYaml -}}
{{- if $service -}}
{{ $servicePort := dig "ports" $portName "port" nil $service -}}
{{- if not (eq $servicePort nil) -}}
{{- $servicePort -}}
{{- end -}}
{{- end -}}
{{- end -}}