**Description** This PR moves the common-library charts back into this repo. **⚙️ Type of change** - [ ] ⚙️ Feature/App addition - [ ] 🪛 Bugfix - [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] 🔃 Refactor of current code **🧪 How Has This Been Tested?** <!-- Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration --> **📃 Notes:** <!-- Please enter any other relevant information here --> **✔️ Checklist:** - [ ] ⚖️ My code follows the style guidelines of this project - [ ] 👀 I have performed a self-review of my own code - [ ] #️⃣ I have commented my code, particularly in hard-to-understand areas - [ ] 📄 I have made corresponding changes to the documentation - [ ] ⚠️ My changes generate no new warnings - [ ] 🧪 I have added tests to this description that prove my fix is effective or that my feature works - [ ] ⬆️ I increased versions for any altered app according to semantic versioning - [ ] I made sure the title starts with `feat(chart-name):`, `fix(chart-name):` or `chore(chart-name):` **➕ App addition** If this PR is an app addition please make sure you have done the following. - [ ] 🖼️ I have added an icon in the Chart's root directory called `icon.png` --- _Please don't blindly check all the boxes. Read them and only check those that apply. Those checkboxes are there for the reviewer to see what is this all about and the status of this PR with a quick glance._ --------- Signed-off-by: TrueCharts-Bot <bot@truecharts.org> Co-authored-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com> Co-authored-by: TrueCharts-Admin <bot@truecharts.org> Co-authored-by: Kjeld Schouten <kjeld@schouten-lebbing.nl> Co-authored-by: Stavros kois <s.kois@outlook.com> Co-authored-by: ばか雪 <165359296+bakayukii@users.noreply.github.com> Co-authored-by: Tete17 <miguel_tete17@hotmail.com> Co-authored-by: Matthew Salazar <matthew@mtslzr.io>
48 lines
1.8 KiB
Smarty
48 lines
1.8 KiB
Smarty
{{/* Service - Get Selected Service */}}
|
|
{{/* Call this template:
|
|
{{ include "tc.v1.common.lib.helpers.getSelectedServiceValues" (dict "rootCtx" $rootCtx "objectData" $objectData) -}}
|
|
objectData: The object data of the service
|
|
rootCtx: The root context of the chart.
|
|
*/}}
|
|
|
|
{{- define "tc.v1.common.lib.helpers.getSelectedServiceValues" -}}
|
|
{{- $rootCtx := .rootCtx -}}
|
|
{{- $objectData := .objectData -}}
|
|
{{- $caller := .caller -}}
|
|
|
|
{{- $serviceValues := dict -}}
|
|
{{- with $objectData.targetSelector -}}
|
|
{{- $serviceValues = mustDeepCopy (get $rootCtx.Values.service .) -}}
|
|
|
|
{{- if not $serviceValues -}}
|
|
{{- fail (printf "%s - Selected service [%s] is not defined" $caller .) -}}
|
|
{{- end -}}
|
|
|
|
{{- if not $serviceValues.enabled -}}
|
|
{{- fail (printf "%s - Selected service [%s] is not enabled" $caller .) -}}
|
|
{{- end -}}
|
|
|
|
{{/* While we know the shortName from targetSelector, let's set it explicitly
|
|
So service can reference this directly, to match the behaviour of a service
|
|
without targetSelector defined (assumes "use primary") */}}
|
|
{{- $_ := set $serviceValues "shortName" . -}}
|
|
{{- else -}}
|
|
|
|
{{/* If no targetSelector is defined, we assume the service is using the primary service */}}
|
|
{{/* Also no need to check for multiple primaries here, it's already done on the service validation */}}
|
|
{{- range $serviceName, $service := $rootCtx.Values.service -}}
|
|
{{- if $service.enabled -}}
|
|
{{- if $service.primary -}}
|
|
{{- $serviceValues = mustDeepCopy $service -}}
|
|
{{/* Set the shortName so service can use this on selector */}}
|
|
{{- $_ := set $serviceValues "shortName" $serviceName -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{/* Return values in Json, to preserve types */}}
|
|
{{ $serviceValues | toJson }}
|
|
{{- end -}}
|