chore(common): add widget version on homepage integration (#29819)

**Description**
<!--
Please include a summary of the change and which issue is fixed. Please
also include relevant motivation and context. List any dependencies that
are required for this change.
-->
⚒️ Fixes  #29818 

**⚙️ Type of change**

- [ ] ⚙️ Feature/App addition
- [ ] 🪛 Bugfix
- [ ] ⚠️ Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [x] 🔃 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:**

- [x] ⚖️ My code follows the style guidelines of this project
- [x] 👀 I have performed a self-review of my own code
- [ ] #️⃣ I have commented my code, particularly in hard-to-understand
areas
- [x] 📄 I have made corresponding changes to the documentation
- [x] ⚠️ My changes generate no new warnings
- [x] 🧪 I have added tests to this description that prove my fix is
effective or that my feature works
- [x] ⬆️ I increased versions for any altered app according to semantic
versioning
- [x] 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._
This commit is contained in:
Stavros Kois
2024-12-11 11:48:43 +02:00
committed by GitHub
parent 12237d520f
commit 56a1632cb0
4 changed files with 72 additions and 35 deletions

View File

@@ -85,6 +85,8 @@ tests:
traefik: *traefik
homepage:
enabled: true
widget:
version: 2
hosts:
- host: "{{ .Values.someHost }}"
paths:
@@ -133,6 +135,7 @@ tests:
gethomepage.dev/widget.url: https://test-release-name-common-test.test-release-namespace.svc:9443
gethomepage.dev/icon: https://truecharts.org/img/hotlink-ok/chart-icons/common-test.webp
gethomepage.dev/widget.type: commontest
gethomepage.dev/widget.version: "1"
gethomepage.dev/pod-selector: app.kubernetes.io/instance=test-release-name,pod.lifecycle in (permanent)
- documentIndex: *ingressDoc
matchRegex:
@@ -165,6 +168,7 @@ tests:
gethomepage.dev/icon: some-icon
gethomepage.dev/widget.url: some-url
gethomepage.dev/weight: "1"
gethomepage.dev/widget.version: "1"
gethomepage.dev/widget.type: some-type
gethomepage.dev/pod-selector: pod.name in (main,other),pod.lifecycle in (permanent)
gethomepage.dev/widget.some-key: some-value
@@ -193,6 +197,7 @@ tests:
gethomepage.dev/widget.url: http://test-release-name-common-test-my-service2.test-release-namespace.svc:80
gethomepage.dev/icon: https://truecharts.org/img/hotlink-ok/chart-icons/common-test.webp
gethomepage.dev/widget.type: commontest
gethomepage.dev/widget.version: "2"
gethomepage.dev/pod-selector: app.kubernetes.io/instance=test-release-name,pod.lifecycle in (permanent)
- documentIndex: *thirdIngressDoc
equal:

View File

@@ -48,4 +48,4 @@ sources:
- https://hub.docker.com/_/
- https://hub.docker.com/r/mikefarah/yq
type: library
version: 25.2.1
version: 25.2.2

View File

@@ -23,6 +23,7 @@
{{- $defaultType = regexReplaceAll "\\W+" $defaultType "" -}}
{{- $type := $homepage.widget.type | default $defaultType -}}
{{- $url := $homepage.widget.url -}}
{{- $version := $homepage.widget.version | default 1 | toString -}}
{{- $href := $homepage.href -}}
{{- if not $href -}}
@@ -64,6 +65,7 @@
{{- if $widEnabled -}}
{{- $_ := set $objectData.annotations "gethomepage.dev/widget.type" (tpl $type $rootCtx) -}}
{{- $_ := set $objectData.annotations "gethomepage.dev/widget.version" (tpl $version $rootCtx) -}}
{{- with $url -}}
{{- $_ := set $objectData.annotations "gethomepage.dev/widget.url" (tpl $url $rootCtx) -}}

View File

@@ -29,8 +29,8 @@ Enables or Disables the homepage integration
| ---------- | --------------------------------------------- |
| Key | `ingress.$name.integrations.homepage.enabled` |
| Type | `bool` |
| Required | ✅ |
| Helm `tpl` | ❌ |
| Required | ✅ |
| Helm `tpl` | ❌ |
| Default | `false` |
Example
@@ -59,8 +59,8 @@ Sets the `gethomepage.dev/name` annotation
| ---------- | ------------------------------------------ |
| Key | `ingress.$name.integrations.homepage.name` |
| Type | `string` |
| Required | ❌ |
| Helm `tpl` | ❌ |
| Required | ❌ |
| Helm `tpl` | ❌ |
| Default | The Release Name |
Example
@@ -89,8 +89,8 @@ Sets the `gethomepage.dev/description` annotation
| ---------- | ------------------------------------------------- |
| Key | `ingress.$name.integrations.homepage.description` |
| Type | `string` |
| Required | ❌ |
| Helm `tpl` | ❌ |
| Required | ❌ |
| Helm `tpl` | ❌ |
| Default | The Description of the Chart |
Example
@@ -119,8 +119,8 @@ Sets the `gethomepage.dev/group` annotation
| ---------- | ------------------------------------------- |
| Key | `ingress.$name.integrations.homepage.group` |
| Type | `string` |
| Required | ❌ |
| Helm `tpl` | ❌ |
| Required | ❌ |
| Helm `tpl` | ❌ |
| Default | `""` |
Example
@@ -149,8 +149,8 @@ Sets the `gethomepage.dev/icon` annotation
| ---------- | ------------------------------------------ |
| Key | `ingress.$name.integrations.homepage.icon` |
| Type | `string` |
| Required | ❌ |
| Helm `tpl` | ❌ |
| Required | ❌ |
| Helm `tpl` | ❌ |
| Default | The Chart Icon |
Example
@@ -179,8 +179,8 @@ Sets the `gethomepage.dev/href` annotation
| ---------- | ------------------------------------------ |
| Key | `ingress.$name.integrations.homepage.href` |
| Type | `string` |
| Required | ❌ |
| Helm `tpl` | ❌ |
| Required | ❌ |
| Helm `tpl` | ❌ |
| Default | The first ingress host |
Example
@@ -209,8 +209,8 @@ Sets the `gethomepage.dev/weight` annotation
| ---------- | -------------------------------------------- |
| Key | `ingress.$name.integrations.homepage.weight` |
| Type | `int` |
| Required | ❌ |
| Helm `tpl` | ❌ |
| Required | ❌ |
| Helm `tpl` | ❌ |
| Default | unset |
Example
@@ -239,8 +239,8 @@ Sets the `gethomepage.dev/pod-selector` annotation
| ---------- | ------------------------------------------------- |
| Key | `ingress.$name.integrations.homepage.podSelector` |
| Type | `list` of `string` |
| Required | ❌ |
| Helm `tpl` | ❌ |
| Required | ❌ |
| Helm `tpl` | ❌ |
| Default | `[]` |
Example
@@ -265,8 +265,8 @@ Define configuration for the widget
| ---------- | -------------------------------------------- |
| Key | `ingress.$name.integrations.homepage.widget` |
| Type | `map` |
| Required | ❌ |
| Helm `tpl` | ❌ |
| Required | ❌ |
| Helm `tpl` | ❌ |
| Default | `{}` |
Example
@@ -285,14 +285,13 @@ ingress:
Enables or Disables the widget
| | |
| ---------- | ---------------------------------------------------- |
| Key | `ingress.$name.integrations.homepage.widget.enabled` |
| Type | `bool` |
| Required | ❌ |
| Helm `tpl` | ❌ |
| Default | `true` |
| Required | ❌ |
| Helm `tpl` | ❌ |
| Default | `true` |
Example
@@ -321,8 +320,8 @@ Sets the `gethomepage.dev/widget.type` annotation
| ---------- | ------------------------------------------------- |
| Key | `ingress.$name.integrations.homepage.widget.type` |
| Type | `string` |
| Required | ❌ |
| Helm `tpl` | ❌ |
| Required | ❌ |
| Helm `tpl` | ❌ |
| Default | The Chart Name |
Example
@@ -338,6 +337,37 @@ ingress:
---
### `widget.version`
Define the version of the widget
:::note
Sets the `gethomepage.dev/widget.version` annotation
:::
| | |
| ---------- | ---------------------------------------------------- |
| Key | `ingress.$name.integrations.homepage.widget.version` |
| Type | `int` |
| Required | ❌ |
| Helm `tpl` | ❌ |
| Default | `1` |
Example
```yaml
ingress:
ingress-name:
integrations:
homepage:
widget:
version: 1
```
---
### `widget.url`
Define the url for the widget
@@ -352,8 +382,8 @@ Sets the `gethomepage.dev/widget.url` annotation
| ---------- | ------------------------------------------------ |
| Key | `ingress.$name.integrations.homepage.widget.url` |
| Type | `string` |
| Required | ❌ |
| Helm `tpl` | ❌ |
| Required | ❌ |
| Helm `tpl` | ❌ |
| Default | The first ingress host |
Example
@@ -383,8 +413,8 @@ Sets the `gethomepage.dev/widget.$key` annotation
| ---------- | --------------------------------------------------- |
| Key | `ingress.$name.integrations.homepage.widget.custom` |
| Type | `map` |
| Required | ❌ |
| Helm `tpl` | ❌ |
| Required | ❌ |
| Helm `tpl` | ❌ |
| Default | `{}` |
Example
@@ -408,8 +438,8 @@ Define custom annotations for the widget as a list
| ---------- | ----------------------------------------------------- |
| Key | `ingress.$name.integrations.homepage.widget.customkv` |
| Type | `list` of `map` |
| Required | ❌ |
| Helm `tpl` | ❌ |
| Required | ❌ |
| Helm `tpl` | ❌ |
| Default | `[]` |
Example
@@ -439,8 +469,8 @@ Sets the `gethomepage.dev/widget.$key` annotation
| ---------- | ----------------------------------------------------------- |
| Key | `ingress.$name.integrations.homepage.widget.customkv[].key` |
| Type | `string` |
| Required | ✅ |
| Helm `tpl` | ❌ |
| Required | ✅ |
| Helm `tpl` | ❌ |
| Default | `""` |
Example
@@ -465,8 +495,8 @@ Define the value for the custom annotation
| ---------- | ------------------------------------------------------------- |
| Key | `ingress.$name.integrations.homepage.widget.customkv[].value` |
| Type | `string` |
| Required | ✅ |
| Helm `tpl` | ❌ |
| Required | ✅ |
| Helm `tpl` | ❌ |
| Default | `""` |
Example