Files
charts/githooks/pre-push/helm-lint
Daniel Arteaga 1d2da656d1 [bitnami/redis] fix: volumeClaimTemplates labels error (#5298)
* [bitnami/redis] fix: volumeClaimTemplates labels error

Signed-off-by: darteaga <darteaga@vmware.com>

* feat(helm-lint): add helm dep update

Signed-off-by: darteaga <darteaga@vmware.com>

Co-authored-by: Andrés Bono <andresbono@vmware.com>
2021-02-02 19:01:31 +01:00

37 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
repo_path="$(git rev-parse --show-toplevel)"
current_branch="$(git rev-parse --abbrev-ref HEAD)"
origin_commit="$(git rev-parse --short "$(git merge-base master "$current_branch")")"
files_to_push="$(git diff --name-only "$origin_commit")"
# shellcheck source=../functions/libhelmlint.sh
. "${repo_path}/githooks/functions/libhelmlint.sh"
failed=0
for chart_name in $( cut -d'/' -f1,2 <<< "$files_to_push" | uniq ); do
# Avoid running 'helm lint|install' when modified dirs are not charts
if [[ $chart_name = bitnami/* ]]; then
printf '\033[01;33mUpdating dependencies for %s with helm dep update:\n\033[0m' "$chart_name"
helm dep update "$chart_name"
printf '\033[01;33mValidating %s with helm lint:\n\033[0m' "$chart_name"
if ! run_helm_lint_chart "$chart_name"; then
failed=1
fi
printf '\033[01;33mDiscard changes in working directory for "%s/Chart.lock\n\033[0m' "$chart_name"
git checkout -- "$chart_name/Chart.lock"
fi
done
if [[ "$failed" = "1" ]]; then
printf '\033[0;31m\U0001F6AB Helm lint failed. Not pushing\n\n\033[0m'
else
printf '\033[0;32m\U00002705 Helm lint succeeded\n\n\033[0m'
fi
exit $failed