-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgovuk-app-linter.sh
executable file
·42 lines (29 loc) · 1.18 KB
/
govuk-app-linter.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
#!/bin/bash
# set -e
ENVIRONMENTS=("integration" "staging" "production")
for env in "${ENVIRONMENTS[@]}"; do
values_filename="./charts/app-config/values-$env.yaml";
array_length=$(yq e ".govukApplications | length - 1" "$values_filename")
if [ "$array_length" -le 0 ] ; then
continue;
fi
echo "=================== $env ===================";
declare -i errors=0;
# expand all the aliases
yq 'explode(.)' "./charts/app-config/values-$env.yaml" > "lint-tmp/$env-exploded.yaml"
for app_index in $(seq 0 "$array_length");do
filename="./lint-tmp/$(yq ".govukApplications[$app_index].name" "$values_filename")-chart.yaml"
chart_path=$(yq ".govukApplications[$app_index].chartPath // \"charts/generic-govuk-app\"" "$values_filename");
echo "$app_index/$array_length: linting $filename against $chart_path";
yq ".govukApplications[$app_index].helmValues" "lint-tmp/$env-exploded.yaml" > "$filename";
output=$(helm lint --quiet -f "$filename" "$chart_path");
if [[ "$output" == *"[ERROR]"* ]]; then
echo "$output";
errors+=1;
fi
done
if [[ errors -gt 0 ]]; then
echo "$errors lint errors found in $env values";
exit 1
fi
done