Skip to content

Commit

Permalink
fix(homepage integration): change structure of custom parameters (#640)
Browse files Browse the repository at this point in the history
**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 <[email protected]>
  • Loading branch information
Kjeld Schouten and stavros-k authored Dec 22, 2023
1 parent 00df932 commit bd0fef2
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 2 deletions.
49 changes: 49 additions & 0 deletions library/common-test/tests/ingress/homepage_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]
2 changes: 1 addition & 1 deletion library/common/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ maintainers:
name: common
sources: null
type: library
version: 16.2.10
version: 16.2.11
14 changes: 14 additions & 0 deletions library/common/templates/lib/ingress/integrations/_homepage.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
Expand All @@ -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 -}}
5 changes: 4 additions & 1 deletion library/common/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit bd0fef2

Please sign in to comment.