HTK: Omit port from uri for http/https when 80/443 used

This PS updates htk to omit the port used in the url when this
corresponds to the standard ports for the http and https protocols.

Change-Id: I46e2237dde99460fd096bd6fe58fe154b220041f
Signed-off-by: Pete Birley <pete@port.direct>
This commit is contained in:
Pete Birley 2019-12-06 17:48:38 -06:00
parent d216fbf731
commit eb5ae14dcd
1 changed files with 6 additions and 1 deletions

View File

@ -16,7 +16,8 @@ limitations under the License.
{{/*
abstract: |
This function helps resolve uri style endpoints
This function helps resolve uri style endpoints. It will omit the port for
http when 80 is used, and 443 in the case of https.
values: |
endpoints:
cluster_domain_suffix: cluster.local
@ -45,5 +46,9 @@ return: |
{{- $endpointHost := tuple $type $endpoint $context | include "helm-toolkit.endpoints.endpoint_host_lookup" }}
{{- $endpointPort := tuple $type $endpoint $port $context | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
{{- $endpointPath := tuple $type $endpoint $port $context | include "helm-toolkit.endpoints.keystone_endpoint_path_lookup" }}
{{- if or ( and ( eq $endpointScheme "http" ) ( eq $endpointPort "80" ) ) ( and ( eq $endpointScheme "https" ) ( eq $endpointPort "443" ) ) -}}
{{- printf "%s://%s%s" $endpointScheme $endpointHost $endpointPath -}}
{{- else -}}
{{- printf "%s://%s:%s%s" $endpointScheme $endpointHost $endpointPort $endpointPath -}}
{{- end -}}
{{- end -}}