2014-12-09 20:10:41 +00:00
|
|
|
#!/bin/bash -e
|
|
|
|
|
|
|
|
# It checks that *.config files respect certain gerrit ACL rules
|
|
|
|
|
2015-06-04 05:30:55 +00:00
|
|
|
export TMPDIR=$(/bin/mktemp -d)
|
2014-12-09 20:10:41 +00:00
|
|
|
trap "rm -rf $TMPDIR" EXIT
|
|
|
|
|
|
|
|
pushd $TMPDIR
|
|
|
|
CONFIGS_LIST_BASE=$OLDPWD/$1
|
|
|
|
|
|
|
|
function check_team_acl {
|
|
|
|
local configs_dir="$1"
|
|
|
|
local configs_list=$(find $configs_dir -name "*.config")
|
|
|
|
local failure=0
|
|
|
|
|
|
|
|
for config in $configs_list; do
|
|
|
|
echo "Checking $config file..."
|
|
|
|
|
2014-12-10 19:37:09 +00:00
|
|
|
$OLDPWD/tools/normalize_acl.py $config all > $TMPDIR/normalized
|
2015-03-06 14:52:06 +00:00
|
|
|
if ! diff -u $config $TMPDIR/normalized >>config_failures;
|
2014-12-09 20:10:41 +00:00
|
|
|
then
|
2014-12-10 19:37:09 +00:00
|
|
|
echo "Project $config is not normalized!" >>config_failures
|
2014-12-09 20:10:41 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
# Add more namespaces here, if necessary
|
2014-12-19 19:34:50 +00:00
|
|
|
for namespace in openstack openstack-dev openstack-infra stackforge; do
|
2014-12-09 20:10:41 +00:00
|
|
|
check_team_acl "${CONFIGS_LIST_BASE}${namespace}"
|
|
|
|
done
|
|
|
|
|
2015-03-06 14:52:06 +00:00
|
|
|
num_errors=$(cat config_failures | grep "is not normalized" | wc -l)
|
|
|
|
if [ $num_errors -ne 0 ]; then
|
2014-12-09 20:10:41 +00:00
|
|
|
echo -e; cat config_failures
|
2014-12-10 19:37:09 +00:00
|
|
|
echo -e "There are $num_errors projects not normalized."
|
2014-12-09 20:10:41 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Gerrit ACL configs are valid!"
|
|
|
|
|
|
|
|
popd
|