-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathgovcms-validate-platform-yml
More file actions
executable file
·55 lines (43 loc) · 1.35 KB
/
govcms-validate-platform-yml
File metadata and controls
executable file
·55 lines (43 loc) · 1.35 KB
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
52
53
54
55
#!/usr/bin/env bash
# shellcheck disable=SC2162,SC2046,SC2002,SC2034
set -euo pipefail
#
# GovCMS validate platform yaml.
#
# Ensures that the necessary Platform files contain
# valid yaml.
#
GOVCMS_PLATFORM_FILES=${GOVCMS_PLATFORM_FILES:-}
GOVCMS_YAML_LINT=${GOVCMS_YAML_LINT:-}
GOVCMS_OUTFILE=${GOVCMS_OUTFILE:-govcms-validate-platform}
FAILURES=""
function join_char { local IFS="$1" shift; echo "$*"; }
echo "GovCMS Validate :: Yaml lint platform files"
if [ -z "${GOVCMS_PLATFORM_FILES}" ]; then
GOVCMS_PLATFORM_FILES=$(find . -type f \( -name '.lagoon.yml' -o -name 'docker-compose.yml' \))
fi
if [ -z "${GOVCMS_YAML_LINT}" ]; then
GOVCMS_YAML_LINT=govcms-yaml_lint
if ! command -v "$GOVCMS_YAML_LINT" > /dev/null 2>&1; then
GOVCMS_YAML_LINT=/app/vendor/bin/govcms-yaml_lint
fi
fi
IFS_BAK="$IFS"
IFS=$'\n'
for file in $GOVCMS_PLATFORM_FILES; do
if ! $GOVCMS_YAML_LINT "$file"; then
echo "[fail]: $file failed lint";
FAILURES="$FAILURES,$file"
fi
done
IFS=$IFS_BAK
if [ -x govcms-prepare-xml ]; then
FILE_LFS=$(join_char , "${GOVCMS_PLATFORM_FILES}")
govcms-prepare-xml --failures="${FAILURES}" --total="${FILE_LFS}" --name="${GOVCMS_OUTFILE}" --fail-message="GovCMS.QA.IllegalPermissions"
fi
if [ -z "${FAILURES}" ]; then
echo "[success]: No YAML issues in platform files."
exit 0
fi
echo "[fail]: YAML problems detected"
exit 1