Add module reset logic for librarian
This change adds the ability to do a reset or an update with the updates_modules.sh script. The reset will do a git reset on the upstream module if there are any manual changes. The update will do a librarian update which will checkout the version specified in the Puppetfile. These changes allow for better development testing as a developer can test manual changes and version changes via the update_modules.sh script. Additionally the fuel_noop_tests.rb script has been updated to support the reset flag for developer testing. Change-Id: Ib21b3ea210b554e1f58bb7a80453989ba8206104 Closes-Bug: 1489542
This commit is contained in:
parent
3864463078
commit
64a0ccc479
@ -27,9 +27,11 @@
|
|||||||
#
|
#
|
||||||
# Parameters:
|
# Parameters:
|
||||||
# -b - Use bundler to install librarian-puppet (optional)
|
# -b - Use bundler to install librarian-puppet (optional)
|
||||||
|
# -r - Hard git reset of librarian managed modules back to specified version (optional)
|
||||||
# -p <puppet_version> - Puppet version to use with bundler (optional)
|
# -p <puppet_version> - Puppet version to use with bundler (optional)
|
||||||
# -h <bundle_dir> - Folder to be used as the home directory for bundler (optional)
|
# -h <bundle_dir> - Folder to be used as the home directory for bundler (optional)
|
||||||
# -g <gem_home> - Folder to be used as the gem directory (optional)
|
# -g <gem_home> - Folder to be used as the gem directory (optional)
|
||||||
|
# -u - Run librarian update (optional)
|
||||||
# -v - Verbose printing, turns on set -x (optional)
|
# -v - Verbose printing, turns on set -x (optional)
|
||||||
# -? - This usage information
|
# -? - This usage information
|
||||||
#
|
#
|
||||||
@ -51,13 +53,15 @@ set -e
|
|||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
Usage: $(basename $0) [-b] [-p <puppet_version>] [-h <bundle_dir>] [-g <gem_home>] [-?]
|
Usage: $(basename $0) [-b] [-r] [-p <puppet_version>] [-h <bundle_dir>] [-g <gem_home>] [-u] [-?]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-b - Use bundler instead of assuming librarian-puppet is available
|
-b - Use bundler instead of assuming librarian-puppet is available
|
||||||
|
-r - Hard git reset of librarian managed modules back to specified version
|
||||||
-p <puppet_version> - Puppet version to use with bundler
|
-p <puppet_version> - Puppet version to use with bundler
|
||||||
-h <bundle_dir> - Folder to be used as the home directory for bundler
|
-h <bundle_dir> - Folder to be used as the home directory for bundler
|
||||||
-g <gem_home> - Folder to be used as the gem directory
|
-g <gem_home> - Folder to be used as the gem directory
|
||||||
|
-u - Run librarian update
|
||||||
-v - Verbose printing of commands
|
-v - Verbose printing of commands
|
||||||
-? - This usage information
|
-? - This usage information
|
||||||
|
|
||||||
@ -65,7 +69,7 @@ EOF
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
while getopts ":bp:l:h:v" opt; do
|
while getopts ":bp:l:h:vru" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
b)
|
b)
|
||||||
USE_BUNDLER=true
|
USE_BUNDLER=true
|
||||||
@ -80,6 +84,12 @@ while getopts ":bp:l:h:v" opt; do
|
|||||||
g)
|
g)
|
||||||
GEM_HOME=$OPTARG
|
GEM_HOME=$OPTARG
|
||||||
;;
|
;;
|
||||||
|
r)
|
||||||
|
RESET_HARD=true
|
||||||
|
;;
|
||||||
|
u)
|
||||||
|
UPDATE=true
|
||||||
|
;;
|
||||||
v)
|
v)
|
||||||
set -x
|
set -x
|
||||||
;;
|
;;
|
||||||
@ -110,5 +120,32 @@ if [ "$USE_BUNDLER" = true ]; then
|
|||||||
bundle update
|
bundle update
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# run librarian-puppet install to populate the modules
|
# Check to make sure if the folder already exists, it has a .git so we can
|
||||||
|
# use git on it. If the mod folder exists, but .git doesn't then remove the mod
|
||||||
|
# folder so it can be properly installed via librarian.
|
||||||
|
for MOD in $(grep "^mod" Puppetfile | tr -d '[:punct:]' | awk '{ print $2 }'); do
|
||||||
|
MOD_DIR="${DEPLOYMENT_DIR}/puppet/${MOD}"
|
||||||
|
if [ -d $MOD_DIR ] && [ ! -d "${MOD_DIR}/.git" ];
|
||||||
|
then
|
||||||
|
rm -rf "${MOD_DIR}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# run librarian-puppet install to populate the modules if they do not already
|
||||||
|
# exist
|
||||||
$BUNDLER_EXEC librarian-puppet install --path=puppet
|
$BUNDLER_EXEC librarian-puppet install --path=puppet
|
||||||
|
|
||||||
|
# run librarian-puppet update to ensure the modules are checked out to the
|
||||||
|
# correct version
|
||||||
|
if [ "$UPDATE" = true ]; then
|
||||||
|
$BUNDLER_EXEC librarian-puppet update --path=puppet
|
||||||
|
fi
|
||||||
|
|
||||||
|
# do a hard reset on the librarian managed modules LP#1489542
|
||||||
|
if [ "$RESET_HARD" = true ]; then
|
||||||
|
for MOD in $(grep "^mod " Puppetfile | tr -d '[:punct:]' | awk '{ print $2 }'); do
|
||||||
|
cd "${DEPLOYMENT_DIR}/puppet/${MOD}"
|
||||||
|
git reset --hard
|
||||||
|
done
|
||||||
|
cd $DEPLOYMENT_DIR
|
||||||
|
fi
|
||||||
|
@ -119,6 +119,9 @@ module NoopTests
|
|||||||
opts.on('-u', '--update-librarian-puppet', 'Run librarian-puppet update in the deployment directory prior to testing') do
|
opts.on('-u', '--update-librarian-puppet', 'Run librarian-puppet update in the deployment directory prior to testing') do
|
||||||
@options[:update_librarian_puppet] = true
|
@options[:update_librarian_puppet] = true
|
||||||
end
|
end
|
||||||
|
opts.on('-r', '--reset-librarian-puppet', 'Reset puppet modules to librarian versions in the deployment directory prior to testing') do
|
||||||
|
@options[:reset_librarian_puppet] = true
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
optparse.parse!
|
optparse.parse!
|
||||||
@ -412,6 +415,9 @@ module NoopTests
|
|||||||
command = './update_modules.sh -v'
|
command = './update_modules.sh -v'
|
||||||
# pass the bundle parameter to update_modules if specified for this script
|
# pass the bundle parameter to update_modules if specified for this script
|
||||||
command = command + ' -b' if options[:bundle]
|
command = command + ' -b' if options[:bundle]
|
||||||
|
# pass the reset parameter to update_modules if specified for this script
|
||||||
|
command = command + ' -r' if options[:reset_librarian_puppet]
|
||||||
|
|
||||||
inside_deployment_directory do
|
inside_deployment_directory do
|
||||||
puts "-> Starting update_modules script"
|
puts "-> Starting update_modules script"
|
||||||
system command
|
system command
|
||||||
|
Loading…
Reference in New Issue
Block a user