Hyunsun Moon | ed19c09 | 2019-07-10 15:24:45 -0600 | [diff] [blame] | 1 | {{- /* |
| 2 | # Copyright 2019-present Open Networking Foundation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | */ -}} |
| 16 | |
| 17 | {{/* |
| 18 | Return endpoint of the given application. |
| 19 | */}} |
| 20 | {{- define "oaisim.endpoint_lookup" -}} |
| 21 | {{- $app := index . 0 -}} |
| 22 | {{- $type := index . 1 -}} |
| 23 | {{- $context := index . 2 -}} |
Hyunsun Moon | 43eadcc | 2019-08-20 16:16:08 -0600 | [diff] [blame] | 24 | {{- $appContext := index $context.Values.config $app -}} |
Hyunsun Moon | ed19c09 | 2019-07-10 15:24:45 -0600 | [diff] [blame] | 25 | {{- $appName := $appContext.name -}} |
| 26 | {{- if eq $type "fqdn" -}} |
| 27 | {{- printf "%s-0.%s.%s.svc.%s" $appName $appName $context.Release.Namespace "cluster.local" -}} |
| 28 | {{- else if eq $type "short" -}} |
| 29 | {{- printf "%s-0.%s" $appName $appName -}} |
| 30 | {{- end -}} |
| 31 | {{- end -}} |
| 32 | |
| 33 | {{/* |
| 34 | Render the given template. |
| 35 | */}} |
| 36 | {{- define "oaisim.template" -}} |
| 37 | {{- $name := index . 0 -}} |
| 38 | {{- $context := index . 1 -}} |
| 39 | {{- $last := base $context.Template.Name }} |
| 40 | {{- $wtf := $context.Template.Name | replace $last $name -}} |
| 41 | {{ include $wtf $context }} |
| 42 | {{- end -}} |
| 43 | |
| 44 | {{/* |
| 45 | Return PLMN from MCC and MNC. |
| 46 | */}} |
| 47 | {{- define "oaisim.plmn" -}} |
| 48 | {{- $mcc := index . 0 -}} |
| 49 | {{- $mnc := index . 1 -}} |
| 50 | {{- printf "%s%s" $mcc $mnc -}} |
| 51 | {{- end -}} |