diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9cef1656..0613b051 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,8 +18,8 @@ repos: files: charts/.*\.yaml$ verbose: true args: - - --quiet - - --compact + - --quiet + - --compact - repo: https://github.com/jtyr/kubeconform-helm rev: v0.1.15 hooks: @@ -40,3 +40,9 @@ repos: args: - --exclude-charts=alfresco-common,alfresco-sync-service - --values-dir=ci + - repo: local + hooks: + - id: custom-check-chart-versions + name: Check Chart dependencies + entry: ./scripts/charts.sh + language: script diff --git a/scripts/charts.sh b/scripts/charts.sh new file mode 100755 index 00000000..2a67776e --- /dev/null +++ b/scripts/charts.sh @@ -0,0 +1,16 @@ +#!/bin/bash -e + +for chart_file in charts/*/Chart.yaml; do + chart_version=$(yq eval '.version' "$chart_file") # Assuming you have yq installed + if [[ "$chart_version" == *-* ]]; then + continue + fi + + dependencies=$(yq eval '.dependencies[] | select(.version | test("-"))' "$chart_file") + if [ -n "$dependencies" ]; then + echo "Chart $chart_file has dependencies with a pre-release version, but the main chart version doesn't." + exit 1 + fi +done + +echo "All charts passed the check."