Wei-Yu Chen | 0f12b9c | 2019-04-18 11:12:59 -0700 | [diff] [blame] | 1 | {{- /* |
| 2 | # Copyright 2018-present Open Networking Foundation |
| 3 | # Copyright 2018 Intel Corporation |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | */ -}} |
| 17 | |
Wei-Yu Chen | 0f12b9c | 2019-04-18 11:12:59 -0700 | [diff] [blame] | 18 | {{/* |
Hyunsun Moon | 06f9855 | 2019-08-15 13:44:47 -0600 | [diff] [blame^] | 19 | abstract: | |
| 20 | Renders a set of standardised labels |
| 21 | usage: | |
| 22 | {{ tuple "mme" . | include "mcord-services.metadata_labels" }} |
| 23 | return: | |
| 24 | release: mcord-services |
| 25 | app: mme |
Wei-Yu Chen | 0f12b9c | 2019-04-18 11:12:59 -0700 | [diff] [blame] | 26 | */}} |
Hyunsun Moon | 06f9855 | 2019-08-15 13:44:47 -0600 | [diff] [blame^] | 27 | {{- define "mcord-services.metadata_labels" -}} |
| 28 | {{- $application := index . 0 -}} |
| 29 | {{- $context := index . 1 -}} |
| 30 | release: {{ $context.Release.Name }} |
| 31 | app: {{ $application }} |
Wei-Yu Chen | 0f12b9c | 2019-04-18 11:12:59 -0700 | [diff] [blame] | 32 | {{- end -}} |
Hyunsun Moon | a24d3f9 | 2019-06-19 03:04:58 -0500 | [diff] [blame] | 33 | |
| 34 | {{/* |
| 35 | Render the given template. |
| 36 | */}} |
| 37 | {{- define "mcord-services.template" -}} |
| 38 | {{- $name := index . 0 -}} |
| 39 | {{- $context := index . 1 -}} |
| 40 | {{- $last := base $context.Template.Name }} |
| 41 | {{- $wtf := $context.Template.Name | replace $last $name -}} |
| 42 | {{ include $wtf $context }} |
| 43 | {{- end -}} |
Hyunsun Moon | 636e17d | 2019-07-03 12:52:15 -0500 | [diff] [blame] | 44 | |
| 45 | {{/* |
| 46 | Return identity, realm, and hostname of the first pod of the given statefulset. |
| 47 | */}} |
| 48 | {{- define "mcord-services.endpoint_lookup" -}} |
| 49 | {{- $service := index . 0 -}} |
| 50 | {{- $type := index . 1 -}} |
| 51 | {{- $context := index . 2 -}} |
Hyunsun Moon | 636e17d | 2019-07-03 12:52:15 -0500 | [diff] [blame] | 52 | {{- if eq $type "identity" -}} |
Hyunsun Moon | 06f9855 | 2019-08-15 13:44:47 -0600 | [diff] [blame^] | 53 | {{- printf "%s-0.%s.%s.svc.%s" $service $service $context.Release.Namespace "cluster.local" -}} |
Hyunsun Moon | 636e17d | 2019-07-03 12:52:15 -0500 | [diff] [blame] | 54 | {{- else if eq $type "realm" -}} |
Hyunsun Moon | 06f9855 | 2019-08-15 13:44:47 -0600 | [diff] [blame^] | 55 | {{- printf "%s.%s.svc.%s" $service $context.Release.Namespace "cluster.local" -}} |
Hyunsun Moon | 636e17d | 2019-07-03 12:52:15 -0500 | [diff] [blame] | 56 | {{- else if eq $type "host" -}} |
Hyunsun Moon | 06f9855 | 2019-08-15 13:44:47 -0600 | [diff] [blame^] | 57 | {{- printf "%s-0" $service -}} |
Hyunsun Moon | 636e17d | 2019-07-03 12:52:15 -0500 | [diff] [blame] | 58 | {{- end -}} |
| 59 | {{- end -}} |