From 28cc47025e0e622f5223fd7aedeebf9bc20b58c7 Mon Sep 17 00:00:00 2001 From: Giovanni Toraldo Date: Wed, 8 Nov 2023 12:53:17 +0100 Subject: [PATCH] Ensure release chart doesn't have pre-release dependencies --- .pre-commit-config.yaml | 10 ++++++++-- scripts/charts.sh | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100755 scripts/charts.sh 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."