mirror of
https://github.com/truecharts/library-charts.git
synced 2026-07-02 23:58:03 -03:00
chore(common): check helm version before everything (#683)
**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 # <!--(issue)--> Adds a pre-flight check for helm version. By default the restriction is set to `>3.9.4` which is know to not work with parts of this library. If the annotation `truecharts.org/min_helm_version` is found then the restriction becomes `>=` + the version defined in the annotation. Currently we can't really "unit test" this, because there is no way to manipulate annotations in the test suites. But we are at least testing that it does not "fail", because if it would, all unittests would fail. --- Additionally updated the upper bound of helm version we run the tests on, and also updated the unittest plugin version. Adjusted some "matchers" in the unittest files to follow the semantic changes in from the unittest plugins. **⚙️ 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:** - [x] ⚖️ My code follows the style guidelines of this project - [x] 👀 I have performed a self-review of my own code - [x] #️⃣ I have commented my code, particularly in hard-to-understand areas - [ ] 📄 I have made corresponding changes to the documentation - [x] ⚠️ My changes generate no new warnings - [ ] 🧪 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 **➕ 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._
This commit is contained in:
20
.github/workflows/common_library_tests.yaml
vendored
20
.github/workflows/common_library_tests.yaml
vendored
@@ -23,7 +23,7 @@ jobs:
|
||||
matrix:
|
||||
helm-version:
|
||||
- v3.12.3
|
||||
- v3.13.3
|
||||
- v3.14.0
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
|
||||
@@ -56,13 +56,13 @@ jobs:
|
||||
name: Unit Tests
|
||||
runs-on: ubuntu-22.04
|
||||
env:
|
||||
helmUnitVersion: 0.3.0
|
||||
helmUnitVersion: 0.4.1
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
helm-version:
|
||||
- v3.12.3
|
||||
- v3.13.3
|
||||
- v3.14.0
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
|
||||
@@ -110,7 +110,7 @@ jobs:
|
||||
# We run tests on Helm version of latest SCALE, fluxcd and latest helm release
|
||||
helm-version:
|
||||
- v3.12.3
|
||||
- v3.13.3
|
||||
- v3.14.0
|
||||
values:
|
||||
- basic-values.yaml
|
||||
- configmap-values.yaml
|
||||
@@ -215,7 +215,8 @@ jobs:
|
||||
fi
|
||||
if [[ "${{ matrix.values }}" =~ ingress.*-values.yaml ]]; then
|
||||
helm install cert-manager oci://tccr.io/truecharts/cert-manager --namespace cert-manager --create-namespace --wait
|
||||
helm install traefik oci://tccr.io/truecharts/traefik --namespace traefik --create-namespace --wait
|
||||
helm install traefik oci://tccr.io/truecharts/traefik --namespace traefik --create-namespace --wait \
|
||||
--set service.main.type=ClusterIP --set service.tcp.type=ClusterIP
|
||||
fi
|
||||
|
||||
- name: Run chart-testing (install)
|
||||
@@ -257,7 +258,7 @@ jobs:
|
||||
# # We run tests on Helm version of latest SCALE release
|
||||
# helm-version:
|
||||
# - v3.12.3
|
||||
# - v3.13.3
|
||||
# - v3.14.0
|
||||
# values:
|
||||
# - basic-values.yaml
|
||||
# - configmap-values.yaml
|
||||
@@ -321,7 +322,7 @@ jobs:
|
||||
# # We run tests on Helm version of latest SCALE release
|
||||
# helm-version:
|
||||
# - v3.12.3
|
||||
# - v3.13.3
|
||||
# - v3.14.0
|
||||
# values:
|
||||
# - ingress-values.yaml
|
||||
# - metrics-values.yaml
|
||||
@@ -342,7 +343,8 @@ jobs:
|
||||
# run: |
|
||||
# helm install prometheus-operator oci://tccr.io/truecharts/prometheus-operator --namespace prometheus-operator --create-namespace --wait
|
||||
# helm install cloudnative-pg oci://tccr.io/truecharts/cloudnative-pg --namespace cloudnative-pg --create-namespace --wait
|
||||
# helm install traefik oci://tccr.io/truecharts/traefik --namespace traefik --create-namespace --wait
|
||||
# helm install traefik oci://tccr.io/truecharts/traefik --namespace traefik --create-namespace --wait \
|
||||
# --set service.main.type=ClusterIP --set service.tcp.type=ClusterIP
|
||||
#
|
||||
# - name: Checkout
|
||||
# uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
|
||||
@@ -379,7 +381,7 @@ jobs:
|
||||
# # We run tests on Helm version of latest SCALE release
|
||||
# helm-version:
|
||||
# - v3.12.3
|
||||
# - v3.13.3
|
||||
# - v3.14.0
|
||||
# values:
|
||||
# - vpn-gluetun-values.yaml
|
||||
# - vpn-tailscale-values.yaml
|
||||
|
||||
@@ -13,7 +13,7 @@ keywords:
|
||||
- truecharts
|
||||
- common
|
||||
- test
|
||||
kubeVersion: '>=1.16.0-0'
|
||||
kubeVersion: '>=1.24.0-0'
|
||||
maintainers:
|
||||
- email: info@truecharts.org
|
||||
name: TrueCharts
|
||||
@@ -23,3 +23,5 @@ sources:
|
||||
- https://github.com/truecharts/apps/tree/master/charts/library/common-test
|
||||
type: application
|
||||
version: 1.0.0
|
||||
annotations:
|
||||
truecharts.org/min_helm_version: "3.12"
|
||||
|
||||
@@ -424,7 +424,7 @@ tests:
|
||||
isAPIVersion:
|
||||
of: apps/v1
|
||||
- documentIndex: *otherDeploymentDoc
|
||||
isNull:
|
||||
isNullOrEmpty:
|
||||
path: spec.template.spec.runtimeClassName
|
||||
- documentIndex: *otherDeploymentDoc
|
||||
isSubset:
|
||||
@@ -488,7 +488,7 @@ tests:
|
||||
isAPIVersion:
|
||||
of: apps/v1
|
||||
- documentIndex: *deploymentDoc
|
||||
isNull:
|
||||
isNullOrEmpty:
|
||||
path: spec.template.spec.runtimeClassName
|
||||
- documentIndex: *deploymentDoc
|
||||
isSubset:
|
||||
@@ -620,7 +620,7 @@ tests:
|
||||
isAPIVersion:
|
||||
of: apps/v1
|
||||
- documentIndex: *otherDeploymentDoc
|
||||
isNull:
|
||||
isNullOrEmpty:
|
||||
path: spec.template.spec.runtimeClassName
|
||||
- documentIndex: *otherDeploymentDoc
|
||||
isSubset:
|
||||
|
||||
@@ -229,7 +229,7 @@ tests:
|
||||
isAPIVersion:
|
||||
of: apps/v1
|
||||
- documentIndex: *deploymentDoc
|
||||
isNull:
|
||||
isNullOrEmpty:
|
||||
path: spec.template.spec.initContainers
|
||||
|
||||
- it: should add NVIDIA_VISIBLE_DEVICES=void to init container without GPU
|
||||
|
||||
@@ -230,7 +230,7 @@ tests:
|
||||
isAPIVersion:
|
||||
of: apps/v1
|
||||
- documentIndex: *deploymentDoc
|
||||
isNull:
|
||||
isNullOrEmpty:
|
||||
path: spec.template.spec.initContainers
|
||||
|
||||
- it: should add NVIDIA_VISIBLE_DEVICES=void to init container without GPU
|
||||
|
||||
@@ -20,7 +20,7 @@ tests:
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *deploymentDoc
|
||||
isNull:
|
||||
isNullOrEmpty:
|
||||
path: spec.template.spec.runtimeClassName
|
||||
|
||||
- it: should pass with runtimeClassName from "global"
|
||||
@@ -148,7 +148,7 @@ tests:
|
||||
podSpec: {}
|
||||
asserts:
|
||||
- documentIndex: *deploymentDoc
|
||||
isNull:
|
||||
isNullOrEmpty:
|
||||
path: spec.template.spec.runtimeClassName
|
||||
|
||||
- it: should pass with runtimeClassName from ixChartContext without targetSelector (on primary workload)
|
||||
@@ -186,7 +186,7 @@ tests:
|
||||
isKind:
|
||||
of: CronJob
|
||||
- documentIndex: *cronJobDoc
|
||||
isNull:
|
||||
isNullOrEmpty:
|
||||
path: spec.jobTemplate.spec.template.spec.runtimeClassName
|
||||
|
||||
- it: should pass with runtimeClassName not set from ixChartContext without gpu value
|
||||
|
||||
@@ -7,7 +7,7 @@ keywords:
|
||||
- truecharts
|
||||
- library-chart
|
||||
- common
|
||||
kubeVersion: '>=1.16.0-0'
|
||||
kubeVersion: '>=1.24.0-0'
|
||||
maintainers:
|
||||
- email: info@truecharts.org
|
||||
name: TrueCharts
|
||||
|
||||
20
library/common/templates/lib/chart/_check_capabitilies.tpl
Normal file
20
library/common/templates/lib/chart/_check_capabitilies.tpl
Normal file
@@ -0,0 +1,20 @@
|
||||
{{- define "tc.v1.common.check.capabilities" -}}
|
||||
{{- $helmVersion := .Capabilities.HelmVersion.Version -}}
|
||||
{{- $helmVerCond := ">3.9.4" -}}
|
||||
|
||||
{{- if .Chart.Annotations -}}
|
||||
{{- $min := index .Chart.Annotations "truecharts.org/min_helm_version" -}}
|
||||
{{- if $min -}}
|
||||
{{/* Apply a relaxed version check */}}
|
||||
{{- $helmVerCond = printf ">=%s" $min -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if not (semverCompare $helmVerCond $helmVersion) -}}
|
||||
{{- if .Values.global.ixChartContext -}}
|
||||
{{- fail (printf "Expected helm version [%s], but found [%s]. Upgrade TrueNAS SCALE OS" $helmVerCond $helmVersion) -}}
|
||||
{{- else -}}
|
||||
{{- fail (printf "Expected helm version [%s], but found [%s]. Upgrade helm cli tool." $helmVerCond $helmVersion) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -12,7 +12,7 @@
|
||||
{{- if (hasKey $objectData.schedData "backupOwnerReference") -}}
|
||||
{{- $validOwnerRefs := (list "none" "self" "cluster") -}}
|
||||
{{- if not (mustHas $objectData.schedData.backupOwnerReference $validOwnerRefs) -}}
|
||||
{{- fail (printf "CNPG Scheduled Backup - Expected [backupOwnerReference] in [backups.scheduledBackups] entry to be one of [%s], but got [%s] " (join ", " $validOwnerRefs) $objectData.schedData.backupOwnerReference) -}}
|
||||
{{- fail (printf "CNPG Scheduled Backup - Expected [backupOwnerReference] in [backups.scheduledBackups] entry to be one of [%s], but got [%s]" (join ", " $validOwnerRefs) $objectData.schedData.backupOwnerReference) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
{{/* Initialiaze values of the chart */}}
|
||||
{{- define "tc.v1.common.loader.init" -}}
|
||||
|
||||
{{- include "tc.v1.common.check.capabilities" . -}}
|
||||
|
||||
{{/* Merge chart values and the common chart defaults */}}
|
||||
{{- include "tc.v1.common.values.init" . -}}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user