Skip to content

Commit

Permalink
Add govuk-app-linter.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
kentsanggds committed Feb 7, 2025
1 parent 5d4c4a1 commit c21a8cb
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions govuk-app-linter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash
# set -e

ENVIRONMENTS=("integration" "staging" "production")

for env in "${ENVIRONMENTS[@]}"; do
array_length=$(yq e ".govukApplications | length - 1" "./charts/app-config/ci/$env-values.yaml")

if [ "$array_length" -le 0 ] ; then
continue;
fi

echo "=================== $env ===================";

declare -i errors=0;

# expand all the aliases
yq 'explode(.)' "./charts/app-config/ci/$env-values.yaml" > "lint-tmp/$env-exploded.yaml"

for app_index in $(seq 0 "$array_length");do
filename="./lint-tmp/$(yq e ".govukApplications[$app_index].name" "./charts/app-config/ci/$env-values.yaml")-chart.yaml"

echo "$app_index/$array_length: linting $filename";

yq e ".govukApplications[$app_index].helmValues" "lint-tmp/$env-exploded.yaml" > "$filename";

output=$(helm lint --quiet -f "$filename" ./charts/generic-govuk-app)
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

0 comments on commit c21a8cb

Please sign in to comment.