-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelm-ct.sh
executable file
·46 lines (35 loc) · 1.14 KB
/
helm-ct.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
# shellcheck disable=SC2034
set -eu -o pipefail
CT_ARGS=("$@")
echo "+ setting a clean helm environment"
HELM_HOME="$(mktemp -d)"
HELM_CACHE_HOME="$HELM_HOME/cache"
HELM_CONFIG_HOME="$HELM_HOME/config"
HELM_DATA_HOME="$HELM_HOME/data"
KUBECONFIG="$(mktemp -d)/kubeconfig"
touch "$KUBECONFIG" && chmod 600 "$KUBECONFIG"
echo "+ building helm dependencies"
INITIAL_DIR="$(realpath .)"
find . -name Chart.yaml -exec dirname {} \; | while read -r chartdir; do
echo "+ building dependencies for $chartdir"
cd "$chartdir" || exit 1
i=0; for url in $(yq '.dependencies' Chart.yaml -o=json | jq -r '.[].repository'); do
echo "${url}" | grep -qE '^(https?|git)://' || continue
i=$((i+1)); helm repo add repo-${i} "${url}"
helm repo update repo-${i}
done
cd - || exit 1
done
cd "$INITIAL_DIR" || exit 1
echo "+ running helm chart testing (ct) linter"
find . -name ct.yaml -exec dirname {} \; | while read -r ctdir; do
echo "+ running ct lint from $ctdir"
cd "$ctdir" || exit 1
set -x
ct lint "${CT_ARGS[@]}"
done
echo "+ cleaning helm environment"
rm -rf "$HELM_HOME"
echo "+ helm chart testing (ct) linter completed"
exit 0