project-config/tools/check_valid_gerrit_config.sh
Brian Rosmaita 60de765fa0 Implement openstack-unmaintained-core group
Create a gerrit group to handle branches in Unmaintained status
across all projects, as described in TC resolution 2023-11-14,
which is commit 90982cd in the governance repository.

Also adjust the acl file normalization tool so that it will guarantee
that the Release Managers group has 'abandon' permission on
Unmaintained branches if any project chooses to override the global
openstack-unmaintained-core group with a project-specific unmaintained
core team (as is allowed by TC resolution 2023-11-14).  This entails
a change in that script to require the acl file's namespace be passed
in so that the check doesn't affect non-OpenStack OpenInfra projects.

Change-Id: Ife8e5f175cb8a7d396dfe2a5d52fd6d524ae0b43
2023-11-29 21:48:10 -05:00

55 lines
1.4 KiB
Bash
Executable File

#!/bin/bash -e
# It checks that *.config files respect certain gerrit ACL rules
TMPDIR=$(mktemp -d)
export TMPDIR
trap "rm -rf $TMPDIR" EXIT
pushd $TMPDIR
CONFIGS_LIST_BASE=$OLDPWD/gerrit/acls
declare -i NUM_TESTS=0
function check_team_acl {
local configs_dir="$1"
local namespace
local configs_list
namespace="$(basename $configs_dir)"
echo "Checking $namespace"
configs_list=$(find $configs_dir -name "*.config")
for config in $configs_list; do
let "NUM_TESTS+=1"
$OLDPWD/tools/normalize_acl.py $namespace $config all \
> $TMPDIR/normalized
if ! diff -u $config $TMPDIR/normalized >>config_failures;
then
echo "Project $config is not normalized!" >>config_failures
fi
done
}
# Add more namespaces here, if necessary
for namespace in $CONFIGS_LIST_BASE/*; do
if [ -d $namespace ] ; then
check_team_acl "${namespace}"
fi
done
num_errors=$(cat config_failures | grep "is not normalized" | wc -l)
if [ $num_errors -ne 0 ]; then
echo -e; cat config_failures
echo -e "There are $num_errors projects not normalized."
echo
echo -e "******************************************************"
$OLDPWD/tools/normalize_acl.py -help
echo -e "******************************************************"
exit 1
fi
echo "Gerrit ACL configs are valid!"
echo "Checked $NUM_TESTS ACL files"
popd