|
| 1 | +# This file is required because we use a slightly different endpoint layout in |
| 2 | +# the values yaml, until we can make this change for all services. |
| 3 | + |
| 4 | + |
| 5 | +# this function returns the endpoint uri for a service, it takes an tuple |
| 6 | +# input in the form: service-type, endpoint-class, port-name. eg: |
| 7 | +# { tuple "orchestration" "public" "api" . | include "endpoint_type_lookup_addr" } |
| 8 | +# will return the appropriate URI. Once merged this should phase out the above. |
| 9 | + |
| 10 | +{{- define "endpoint_type_lookup_addr" -}} |
| 11 | +{{- $type := index . 0 -}} |
| 12 | +{{- $endpoint := index . 1 -}} |
| 13 | +{{- $port := index . 2 -}} |
| 14 | +{{- $context := index . 3 -}} |
| 15 | +{{- $endpointMap := index $context.Values.endpoints $type }} |
| 16 | +{{- $fqdn := $context.Release.Namespace -}} |
| 17 | +{{- if $context.Values.endpoints.fqdn -}} |
| 18 | +{{- $fqdn := $context.Values.endpoints.fqdn -}} |
| 19 | +{{- end -}} |
| 20 | +{{- with $endpointMap -}} |
| 21 | +{{- $endpointScheme := .scheme }} |
| 22 | +{{- $endpointHost := index .hosts $endpoint | default .hosts.default}} |
| 23 | +{{- $endpointPort := index .port $port }} |
| 24 | +{{- $endpointPath := .path }} |
| 25 | +{{- printf "%s://%s.%s:%1.f%s" $endpointScheme $endpointHost $fqdn $endpointPort $endpointPath | quote -}} |
| 26 | +{{- end -}} |
| 27 | +{{- end -}} |
| 28 | + |
| 29 | + |
| 30 | +#------------------------------- |
| 31 | +# endpoint name lookup |
| 32 | +#------------------------------- |
| 33 | + |
| 34 | +# this function is used in endpoint management templates |
| 35 | +# it returns the service type for an openstack service eg: |
| 36 | +# { tuple orchestration . | include "ks_endpoint_type" } |
| 37 | +# will return "heat" |
| 38 | + |
| 39 | +{{- define "endpoint_name_lookup" -}} |
| 40 | +{{- $type := index . 0 -}} |
| 41 | +{{- $context := index . 1 -}} |
| 42 | +{{- $endpointMap := index $context.Values.endpoints $type }} |
| 43 | +{{- $endpointName := index $endpointMap "name" }} |
| 44 | +{{- $endpointName | quote -}} |
| 45 | +{{- end -}} |
0 commit comments