X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=kubernetes%2Fcommon%2Fcommon%2Ftemplates%2F_service.tpl;h=3d745ed81952c13bbe81d7009428f2e415bec576;hb=e5dd0a0d3686271379a909be94d4fb9615f60649;hp=15c1f6fbb177b3c4d0e74e83e5baff753c1b29f0;hpb=8a4a2669d8e74b5b4e792ede6124c3a3dc84e7d9;p=oom.git diff --git a/kubernetes/common/common/templates/_service.tpl b/kubernetes/common/common/templates/_service.tpl index 15c1f6fbb1..3d745ed819 100644 --- a/kubernetes/common/common/templates/_service.tpl +++ b/kubernetes/common/common/templates/_service.tpl @@ -302,3 +302,33 @@ true {{- end }} {{- end }} {{- end -}} + +{{- define "common.port.buildCache" -}} + {{- $global := . }} + {{- if not $global.Values._DmaapDrNodePortsCache }} + {{- $portCache := dict }} + {{- range $port := .Values.service.ports }} + {{- $_ := set $portCache $port.name (dict "port" $port.port "plain_port" $port.plain_port) }} + {{- end }} + {{- $_ := set $global.Values "_DmaapDrNodePortsCache" $portCache }} + {{- end }} +{{- end -}} + +{/* + Get Port value according to its name and if we want tls or plain port. + The template takes below arguments: + - .global: environment (.) + - .name: name of the port + - .getPlain: boolean allowing to choose between tls (false, default) or + plain (true) + If plain_port is not set and we ask for plain, it will return empty. +*/} +{{- define "common.getPort" -}} + {{- $global := .global }} + {{- $name := .name }} + {{- $getPlain := default false .getPlain }} + {{- include "common.port.buildCache" $global }} + {{- $portCache := $global.Values._DmaapDrNodePortsCache }} + {{- $port := index $portCache $name }} + {{- ternary $port.plain_port $port.port $getPlain }} +{{- end -}}