-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy pathvalidate-ci-build-clusters.sh
executable file
·62 lines (51 loc) · 1.58 KB
/
validate-ci-build-clusters.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
55
56
57
58
59
60
61
62
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail
workdir="$( mktemp -d )"
trap 'rm -rf "${workdir}"' EXIT
base_dir="${1:-}"
kubeconfig_dir="${2:-}"
kubeconfig_suffix="${3:-}"
if [[ ! -d "${base_dir}" ]]; then
echo "Expected a path to a directory with release repo layout"
exit 1
fi
if [[ ! -d "${kubeconfig_dir}" ]]; then
echo "Expected a path to a directory with valid kubeconfigs"
exit 1
fi
if [[ "${kubeconfig_suffix}" == "" ]]; then
echo "Expected kubeconfig suffix"
exit 1
fi
releaserepo_workdir="${workdir}/release"
mkdir -p "$releaserepo_workdir"
cp -r "${base_dir}/"* "${releaserepo_workdir}"
cluster-init onboard config update \
--release-repo="$releaserepo_workdir" \
--kubeconfig-dir="$kubeconfig_dir" \
--kubeconfig-suffix="$kubeconfig_suffix"
declare -a files=(
"/clusters/app.ci"
"/clusters/build-clusters"
"/ci-operator/jobs/openshift/release"
"/core-services/ci-secret-bootstrap"
"/core-services/ci-secret-generator"
"/core-services/sanitize-prow-jobs"
"/core-services/sync-rover-groups"
)
exitCode=0
for i in "${files[@]}"
do
if ! diff -Naupr "${base_dir}$i" "${releaserepo_workdir}$i" > "${releaserepo_workdir}/diff"; then
echo ERROR: The configuration in "$i" does not match the expected generated configuration, diff:
cat "${releaserepo_workdir}/diff"
exitCode=1
fi
done
if [ "$exitCode" = 1 ]; then
echo ERROR: Run the following command to update the build cluster configs:
echo ERROR: $ make update-ci-build-clusters
fi
exit "$exitCode"