From 56a1632cb0729f6bc4802135c8bf9625e4761345 Mon Sep 17 00:00:00 2001 From: Stavros Kois <47820033+stavros-k@users.noreply.github.com> Date: Wed, 11 Dec 2024 11:48:43 +0200 Subject: [PATCH] chore(common): add widget version on homepage integration (#29819) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Description** ⚒️ 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?** **📃 Notes:** **✔️ 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._ --- .../tests/ingress/homepage_test.yaml | 5 + charts/library/common/Chart.yaml | 2 +- .../lib/ingress/integrations/_homepage.tpl | 2 + .../content/docs/common/ingress/homepage.md | 98 ++++++++++++------- 4 files changed, 72 insertions(+), 35 deletions(-) diff --git a/charts/library/common-test/tests/ingress/homepage_test.yaml b/charts/library/common-test/tests/ingress/homepage_test.yaml index a6918ec7a94..3dab73b6e10 100644 --- a/charts/library/common-test/tests/ingress/homepage_test.yaml +++ b/charts/library/common-test/tests/ingress/homepage_test.yaml @@ -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: diff --git a/charts/library/common/Chart.yaml b/charts/library/common/Chart.yaml index 149f1b38308..86d052a714e 100644 --- a/charts/library/common/Chart.yaml +++ b/charts/library/common/Chart.yaml @@ -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 diff --git a/charts/library/common/templates/lib/ingress/integrations/_homepage.tpl b/charts/library/common/templates/lib/ingress/integrations/_homepage.tpl index ee4089c3bd9..9a400c85872 100644 --- a/charts/library/common/templates/lib/ingress/integrations/_homepage.tpl +++ b/charts/library/common/templates/lib/ingress/integrations/_homepage.tpl @@ -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) -}} diff --git a/website/src/content/docs/common/ingress/homepage.md b/website/src/content/docs/common/ingress/homepage.md index 2dbcbaf1ca7..92e607cadc4 100644 --- a/website/src/content/docs/common/ingress/homepage.md +++ b/website/src/content/docs/common/ingress/homepage.md @@ -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