Skip to content

Commit

Permalink
chore(common): add widget version on homepage integration (truecharts…
Browse files Browse the repository at this point in the history
…#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  truecharts#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._
  • Loading branch information
stavros-k authored Dec 11, 2024
1 parent 12237d5 commit 56a1632
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 35 deletions.
5 changes: 5 additions & 0 deletions charts/library/common-test/tests/ingress/homepage_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ tests:
traefik: *traefik
homepage:
enabled: true
widget:
version: 2
hosts:
- host: "{{ .Values.someHost }}"
paths:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion charts/library/common/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
Expand Down Expand Up @@ -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) -}}
Expand Down
98 changes: 64 additions & 34 deletions website/src/content/docs/common/ingress/homepage.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 56a1632

Please sign in to comment.