-
Notifications
You must be signed in to change notification settings - Fork 154
/
Copy pathtests.sh
executable file
·54 lines (48 loc) · 1.81 KB
/
tests.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
52
53
54
#!/usr/bin/env bash
set -e
reset="$(printf '\033[0m')"
green="$(printf '\033[38;5;46m')"
yellow="$(printf '\033[38;5;178m')"
orange="$(printf '\033[38;5;208m')"
orange_emphasis="$(printf '\033[38;5;220m')"
lightblue="$(printf '\033[38;5;147m')"
red="$(printf '\033[91m')"
gray="$(printf '\033[38;5;245m')"
emphasis="$(printf '\033[38;5;111m')"
underline="$(printf '\033[4m')"
SCRIPT_DIR="$( pwd; )/$( dirname -- $0; )"
cd "${SCRIPT_DIR}"
FIND="find"
mkdir -p fixtures
# Brew installs GNU find as "gfind" by default
if command -v gfind >/dev/null 2>&2; then
FIND="$(which gfind)"
fi
do_the_test() {
local i="${1}" v
printf '%s' "${gray}☆☆☆☆☆☆☆☆☆☆${reset} ${orange_emphasis}$i${reset}: ${gray}☆☆☆☆☆☆☆☆☆☆${reset}"
echo
for v in 1.22.9 1.29.4; do
printf '%s' "${emphasis}${lightblue}k8s v${v}${reset}${lightblue}... ${reset}"
helm template -f "${i}" --kube-version "${v}" --dry-run mail > fixtures/demo.yaml
docker run \
-v "${SCRIPT_DIR}/fixtures:/fixtures" \
-v "${SCRIPT_DIR}/schemas:/schemas" \
ghcr.io/yannh/kubeconform:latest-alpine \
-summary -debug -kubernetes-version "${v}" \
-cache "./schemas/cached" \
-schema-location "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/{{ .NormalizedKubernetesVersion }}-standalone{{ .StrictSuffix }}/{{ .ResourceKind }}{{ .KindSuffix }}.json" \
-schema-location "./schemas/master-standalone/{{ .ResourceKind }}{{ .KindSuffix }}.json" \
fixtures/demo.yaml
done
}
if [[ $# -gt 0 ]]; then
while [[ $# -gt 0 ]]; do
do_the_test "${1}"
shift
done
else
for i in `${FIND} -maxdepth 1 -type f -name test\*yml | sort`; do
do_the_test "${i}"
done
fi