forked from yaseenisolated/helm-kubeval-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
executable file
·51 lines (44 loc) · 1.59 KB
/
entrypoint.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
47
48
49
50
51
#!/bin/sh -l
# Exit on error.
set -e;
CURRENT_DIR=$(pwd);
run_kubeval() {
# Validate all generated manifest against Kubernetes json schema
cd "$1"
VALUES_FILE="$2"
mkdir -p helm-output;
ENVIRONMENT=$(echo "$VALUES_FILE" | cut -f1 -d-)
ENV=${ENVIRONMENT:0:4}
helm template --set=env=$ENV --set=environment=$ENVIRONMENT --values "$VALUES_FILE" --output-dir helm-output .;
find helm-output -type f -exec \
/kubeval/kubeval \
"-o=$OUTPUT" \
"--strict=$STRICT" \
"--kubernetes-version=$KUBERNETES_VERSION" \
"--openshift=$OPENSHIFT" \
"--ignore-missing-schemas=$IGNORE_MISSING_SCHEMAS" \
"--schema-location=https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master" \
{} +;
rm -rf helm-output;
}
# Parse helm repos located in the $CONFIG_FILE file / Ignore commented lines (#)
while read REPO_CONFIG
do
case "$REPO_CONFIG" in \#*) continue ;; esac
REPO=$(echo $REPO_CONFIG | cut -d '=' -f1);
URL=$(echo $REPO_CONFIG | cut -d '=' -f2);
helm repo add $REPO $URL;
done < "$CONFIG_FILE"
helm repo update
# For all charts (i.e for every directory) in the directory
for CHART in "$CHARTS_PATH"/*/; do
echo "Chart is $CHART"
cd "$CURRENT_DIR/$CHART";
helm dependency build --skip-refresh;
for VALUES_FILE in *-values.yaml; do
echo "Validating $CHART Helm Chart using $VALUES_FILE values file...";
run_kubeval "$(pwd)" "$VALUES_FILE"
done
echo "Cleanup $(pwd)/charts directory after we are done running Kubeval"
rm -rf $(pwd)/charts/
done