diff --git a/.github/workflows/helm-package.yml b/.github/workflows/helm-package.yml index 0c1bf93cc..d0b2e6f11 100644 --- a/.github/workflows/helm-package.yml +++ b/.github/workflows/helm-package.yml @@ -80,6 +80,9 @@ jobs: - name: Set up Helm uses: azure/setup-helm@v4.3.0 + - name: Test Helm Chart Templates + run: ./scripts/test_helm_templates.sh + - name: Package Helm Chart run: | set -eux diff --git a/scripts/test_helm_templates.sh b/scripts/test_helm_templates.sh new file mode 100755 index 000000000..a4609b88d --- /dev/null +++ b/scripts/test_helm_templates.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) +CHART_DIR="$ROOT_DIR/helm/rustfs" + +render_standalone_deployment() { + helm template rustfs "$CHART_DIR" \ + --namespace rustfs \ + --set mode.distributed.enabled=false \ + --set mode.standalone.enabled=true \ + "$@" | + awk ' + /^# Source: rustfs\/templates\/deployment.yaml$/ { in_deployment = 1 } + in_deployment && /^---$/ { exit } + in_deployment { print } + ' +} + +recreate_output=$(render_standalone_deployment --set mode.standalone.strategy.type=Recreate) +grep -q "type: Recreate" <<<"$recreate_output" +if grep -q "rollingUpdate:" <<<"$recreate_output"; then + echo "Recreate strategy must not render rollingUpdate fields" >&2 + exit 1 +fi + +rolling_output=$(render_standalone_deployment) +grep -q "type: RollingUpdate" <<<"$rolling_output" +grep -q "rollingUpdate:" <<<"$rolling_output"