fix(homepage integration): change structure of custom parameters (#640)

**Description**
Current parameters system is not displayable in SCALE.


**⚙️ 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

** App addition**

If this PR is an app addition please make sure you have done the
following.

- [ ] 🪞 I have opened a PR on
[truecharts/containers](https://github.com/truecharts/containers) adding
the container to TrueCharts mirror repo.
- [ ] 🖼️ 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._

---------

Co-authored-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com>
This commit is contained in:
Kjeld Schouten
2023-12-22 13:56:50 +01:00
committed by GitHub
parent 00df932e98
commit bd0fef2fa4
4 changed files with 68 additions and 2 deletions

View File

@@ -62,6 +62,11 @@ tests:
custom:
some-key: some-value
some-other-key: some-other-value
customkv:
- key: some-key-slice
value: some-value-slice
- key: some-other-key-slice
value: some-other-value-slice
hosts: &hosts
- host: test-host
paths:
@@ -106,6 +111,8 @@ tests:
gethomepage.dev/pod-selector: pod.name in (main,other)
gethomepage.dev/widget.some-key: some-value
gethomepage.dev/widget.some-other-key: some-other-value
gethomepage.dev/widget.some-key-slice: some-value-slice
gethomepage.dev/widget.some-other-key-slice: some-other-value-slice
- documentIndex: *otherIngressDoc
equal:
path: metadata.name
@@ -154,3 +161,45 @@ tests:
asserts:
- failedTemplate:
errorMessage: Ingress - Expected [integrations.homepage.widget.custom] to be a [map], but got [string]
- it: should fail with customkv widget not a slice
set:
operator: *operator
service: *service
ingress:
my-ingress1:
enabled: true
primary: true
integrations:
traefik:
enabled: false
homepage:
enabled: true
widget:
customkv: "not a slice"
hosts: *hosts
asserts:
- failedTemplate:
errorMessage: Ingress - Expected [integrations.homepage.widget.customkv] to be a [slice], but got [string]
- it: should fail with customkv having empty key
set:
operator: *operator
service: *service
ingress:
my-ingress1:
enabled: true
primary: true
integrations:
traefik:
enabled: false
homepage:
enabled: true
widget:
customkv:
- key: ""
value: some-value
hosts: *hosts
asserts:
- failedTemplate:
errorMessage: Ingress - Expected non-empty [key] in [integrations.homepage.widget.customkv]

View File

@@ -15,4 +15,4 @@ maintainers:
name: common
sources: null
type: library
version: 16.2.10
version: 16.2.11

View File

@@ -46,6 +46,9 @@
{{- range $k, $v := $homepage.widget.custom -}}
{{- $_ := set $objectData.annotations (printf "gethomepage.dev/widget.%s" $k) (tpl $v $rootCtx | toString) -}}
{{- end -}}
{{- range $homepage.widget.customkv -}}
{{- $_ := set $objectData.annotations (printf "gethomepage.dev/widget.%s" .key ) (tpl .value $rootCtx | toString) -}}
{{- end -}}
{{- end -}}
{{- with $homepage.podSelector -}}
@@ -72,4 +75,15 @@
{{- fail (printf "Ingress - Expected [integrations.homepage.widget.custom] to be a [map], but got [%s]" (kindOf $homepage.widget.custom)) -}}
{{- end -}}
{{- end -}}
{{- if $homepage.widget.customkv -}}
{{- if not (kindIs "slice" $homepage.widget.customkv) -}}
{{- fail (printf "Ingress - Expected [integrations.homepage.widget.customkv] to be a [slice], but got [%s]" (kindOf $homepage.widget.customkv)) -}}
{{- end -}}
{{- range $item := $homepage.widget.customkv -}}
{{- if not $item.key -}}
{{- fail "Ingress - Expected non-empty [key] in [integrations.homepage.widget.customkv]" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}

View File

@@ -621,7 +621,10 @@ ingress:
# Default to ingress host 0
url: ""
custom:
# - somesetting: some value
# somesetting: some value
customkv:
# - key: some key
# value: some value
certificate: {}
# main: