feat(common): BREAKING CHANGE refactor add-on system (#31167)

**Description**

This PR updates the add-on system to allow for more end-user flexibility
It basically moves add-on container configuration to values.yaml, to
expose all container options to end users.

Fixes: #27351
Fixes: #31876

**⚙️ 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: Kjeld Schouten <info@kjeldschouten.nl>
Signed-off-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com>
Co-authored-by: kqmaverick <kqmaverick@gmail.com>
Co-authored-by: Stavros Kois <s.kois@outlook.com>
Co-authored-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com>
This commit is contained in:
Kjeld Schouten
2025-03-02 16:14:39 +01:00
committed by GitHub
co-authored by kqmaverick Stavros Kois Stavros Kois
parent 78377b9443
commit b62e536593
36 changed files with 1336 additions and 1986 deletions
@@ -144,8 +144,17 @@ objectData:
{{/* Call this template:
{{ include "tc.v1.common.lib.ingress.primaryValidation" $ -}}
*/}}
{{- define "tc.v1.common.lib.ingress.primaryValidation" -}}
{{- $result := (include "tc.v1.common.lib.ingress.hasPrimary" $) | fromJson -}}
{{/* Require at least one primary ingress, if any enabled */}}
{{- if and $result.hasEnabled (not $result.hasPrimary) -}}
{{- fail "Ingress - At least one enabled ingress must be primary" -}}
{{- end -}}
{{- end -}}
{{- define "tc.v1.common.lib.ingress.hasPrimary" -}}
{{/* Initialize values */}}
{{- $hasPrimary := false -}}
@@ -176,9 +185,5 @@ objectData:
{{- end -}}
{{- end -}}
{{/* Require at least one primary ingress, if any enabled */}}
{{- if and $hasEnabled (not $hasPrimary) -}}
{{- fail "Ingress - At least one enabled ingress must be primary" -}}
{{- end -}}
{{- (dict "hasPrimary" $hasPrimary "hasEnabled" $hasEnabled) | toJson -}}
{{- end -}}
@@ -26,9 +26,9 @@ objectData: The object data to be used to render the Pod.
{{- $deviceAdded := false -}}
{{- $hostUsers := false -}}
{{- $hostUserPersistence := (list "configmap" "secret" "emptyDir" "downwardAPI" "projected") -}}
{{- $podSelected := false -}}
{{- range $persistenceName, $persistenceValues := $rootCtx.Values.persistence -}}
{{- $podSelected := false -}}
{{- $enabled := (include "tc.v1.common.lib.util.enabled" (dict
"rootCtx" $rootCtx "objectData" $persistenceValues
"name" $persistenceName "caller" "Pod Security Context"
@@ -40,7 +40,7 @@ objectData: The object data to be used to render the Pod.
{{- if mustHas $objectData.shortName ($persistenceValues.targetSelector | keys) -}}
{{- $podSelected = true -}}
{{- end -}}
{{- else if $objectData.podPrimary -}}
{{- else if $objectData.primary -}}
{{- $podSelected = true -}}
{{- end -}}
{{- end -}}
@@ -65,12 +65,22 @@ objectData:
*/}}
{{- define "tc.v1.common.lib.service.primaryValidation" -}}
{{- $result := (include "tc.v1.common.lib.service.hasPrimary" $) | fromJson -}}
{{/* Require at least one primary service, if any enabled */}}
{{- if and $result.hasEnabled (not $result.hasPrimary) -}}
{{- fail "Service - At least one enabled service must be primary" -}}
{{- end -}}
{{- end -}}
{{- define "tc.v1.common.lib.service.hasPrimary" -}}
{{- $objectData := .objectData -}}
{{/* Initialize values */}}
{{- $hasPrimary := false -}}
{{- $hasEnabled := false -}}
{{- range $name, $service := .Values.service -}}
{{- range $name, $service := $.Values.service -}}
{{- $enabled := "false" -}}
{{- if not (kindIs "invalid" $service.enabled) -}}
@@ -99,24 +109,30 @@ objectData:
{{- end -}}
{{- end -}}
{{/* Require at least one primary service, if any enabled */}}
{{- if and $hasEnabled (not $hasPrimary) -}}
{{- fail "Service - At least one enabled service must be primary" -}}
{{- end -}}
{{- (dict "hasPrimary" $hasPrimary "hasEnabled" $hasEnabled) | toJson -}}
{{- end -}}
{{/* Service Port Primary Validation */}}
{{/* Call this template:
{{ include "tc.v1.common.lib.service.primaryValidation" (dict "objectData" $objectData -}}
objectData:
The ports of the service.
*/}}
{{- define "tc.v1.common.lib.servicePort.primaryValidation" -}}
{{- $objectData := .objectData -}}
{{- $result := (include "tc.v1.common.lib.servicePort.hasPrimary" (dict "objectData" $objectData)) | fromJson -}}
{{/* Require at least one primary service, if any enabled */}}
{{- if and $result.hasEnabled (not $result.hasPrimary) -}}
{{- fail "Service - At least one enabled port in service must be primary" -}}
{{- end -}}
{{- end -}}
{{- define "tc.v1.common.lib.servicePort.hasPrimary" -}}
{{- $objectData := .objectData -}}
{{/* Initialize values */}}
{{- $hasPrimary := false -}}
{{- $hasEnabled := false -}}
@@ -141,9 +157,5 @@ objectData:
{{- end -}}
{{- end -}}
{{/* Require at least one primary service, if any enabled */}}
{{- if and $hasEnabled (not $hasPrimary) -}}
{{- fail "Service - At least one enabled port in service must be primary" -}}
{{- end -}}
{{- (dict "hasPrimary" $hasPrimary "hasEnabled" $hasEnabled) | toJson -}}
{{- end -}}