Add check_uptodate to tools/config
Add a script which can be used to validate a project's sample config and ensure that it remains up to date on every commit. Change-Id: Iee6cc05cad70963f2a151f595ac376c9338f5774
This commit is contained in:
parent
8251bbfaa7
commit
343686b27e
|
@ -10,3 +10,23 @@ Run it by passing the base directory and package name i.e.
|
|||
Watch out for warnings about modules like libvirt, qpid and zmq not
|
||||
being found - these warnings are significant because they result
|
||||
in options not appearing in the generated config file.
|
||||
|
||||
|
||||
|
||||
This check_uptodate.sh tool is used to ensure that the generated sample
|
||||
config file in the OpenStack project source tree is continually kept up
|
||||
to date with the code itself.
|
||||
|
||||
This can be done by adding a hook to tox.ini. For example, if a project
|
||||
already had flake8 enabled in a section like this:
|
||||
|
||||
[testenv.pep8]
|
||||
commands =
|
||||
flake8 {posargs}
|
||||
|
||||
This section would be changed to:
|
||||
|
||||
[testenv.pep8]
|
||||
commands =
|
||||
flake8 {posargs}
|
||||
{toxinidir}/tools/config/check_uptodate.sh
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
PROJECT_NAME=${PROJECT_NAME:-oslo}
|
||||
CFGFILE_NAME=${PROJECT_NAME}.conf.sample
|
||||
|
||||
if [ -e etc/${PROJECT_NAME}/${CFGFILE_NAME} ]; then
|
||||
CFGFILE=etc/${PROJECT_NAME}/${CFGFILE_NAME}
|
||||
elif [ -e etc/${CFGFILE_NAME} ]; then
|
||||
CFGFILE=etc/${CFGFILE_NAME}
|
||||
else
|
||||
echo "${0##*/}: can not find config file"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TEMPDIR=`mktemp -d /tmp/${PROJECT_NAME}.XXXXXX`
|
||||
trap "rm -rf $TEMPDIR" EXIT
|
||||
|
||||
tools/config/generate_sample.sh -b ./ -p ${PROJECT_NAME} -o ${TEMPDIR}
|
||||
|
||||
if ! diff -u ${TEMPDIR}/${CFGFILE_NAME} ${CFGFILE}
|
||||
then
|
||||
echo "${0##*/}: ${PROJECT_NAME}.conf.sample is not up to date."
|
||||
echo "${0##*/}: Please run ${0%%${0##*/}}generate_sample.sh."
|
||||
exit 1
|
||||
fi
|
Loading…
Reference in New Issue